Skip to content

Deeply Nested objects aren't being serialised #2539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
4 tasks
drwharris opened this issue Apr 14, 2020 · 10 comments
Closed
4 tasks

Deeply Nested objects aren't being serialised #2539

drwharris opened this issue Apr 14, 2020 · 10 comments
Milestone

Comments

@drwharris
Copy link

Package + Version

  • @sentry/browser
  • [X ] @sentry/node
  • raven-js
  • raven-node (raven for node)
  • other:

Version:

5.15.4

Description

This seems to have regressed. I have this code to setup Sentry:

import { ExtraErrorData } from '@sentry/integrations';
Sentry.init({
        dsn: 'MYDSN',
        release: `${Settings.name}@${module.exports.version}`,
        integrations: [new ExtraErrorData({ depth: 10 })],
    });


And I get this


{
	"smart_search": {
		"user_id": "[Object]", <<- Note this
		"id": "[Array]", <<- Note this
		"environment": "prod",
		"path": "/checkout/cart",
		"api_key": "<redacted>",
		"event": "<redacted>"
	},
	"original": {
		"UserName": "",
		"DeviceData": "[Object]", <<- Note this
		"Sequence": <redacted>,
		"Url": "<redacted>",
		"Type": "<redacted>",
		"AcquisitionId": "<redacted>",
		"ClientId": "<redacted>",
		"Environment": "<redacted>",
		"Item": "[Object]", <<- Note this
		"SessionId": "<redacted>",
		"Version": "<redacted>",
		"Referer": "<redacted>",
		"Geographical": "[Object]", <<- Note this
		"Fingerprint": "<redacted>",
		"UserAgent": "<redacted>",
		"IpAddress": "<redacted>",
		"EventDate": "[Object]" <<- Note this
	}
}

A quick search finds me #2417 but not why. This seems to be my issue as in the end I am calling setExtra and always have (even in my original issue) so I am going to see if does actually fix it but...

Why does the ExtraErrorData({ depth: 10 }) option no longer work?

Why did this change?

Where is the documentation on normalizeDepth?

What should I actually be doing now? Do I need

Sentry.init({
...
integrations: [new Sentry.Integrations.ExtraErrorData({ depth: 10 })],
normalizeDepth: 5
});

or just

Sentry.init({
...
normalizeDepth: 5
});

@kamilogorek
Copy link
Contributor

@drwharris, unfortunately, you are correct. We had to update the normalization process about 3 months ago in this PR #2404 and it effectively clashed with ExtraErrorData option.

Why does the ExtraErrorData({ depth: 10 }) option no longer work?

It does, however, normalizeDepth has to be set to at least the same depth+1.

Where is the documentation on normalizeDepth?

https://docs.sentry.io/platforms/javascript/#extraerrordata it's missing the above fact. I will update it soon.

What should I actually be doing now? Do I need

Default depth for ExtraErrorData is 3, same as for normalizeDepth.
If that's enough for you, then you only need to set normalizeDepth to 4 (which is as explained before depth+1).

Sorry for the inconvenience. We had to patch this quite rapidly back then.

@kamilogorek
Copy link
Contributor

Closing the issue, as it seems like the original issue has been resolved.
Please do not hesitate to ping me if it is still relevant, and I will happily reopen and work on it.
Cheers!

@hckhanh
Copy link

hckhanh commented Sep 24, 2021

hi @kamilogorek, so the integration ExtraErrorData and normalizeDepth have the same usage, right?

@hckhanh
Copy link

hckhanh commented Sep 24, 2021

For my current init options of Sentry.

Sentry.init({
    environment: get("NODE_ENV").asString(),
    normalizeDepth: get("SENTRY_NORMALIZE_DEPTH").asIntPositive(),
    integrations: (integrations) => [
      ...integrations,
      new Dedupe(),
      new ReportingObserver(),
      new CaptureConsole({ levels: ["warn", "error"] }),
    ],
  });

I don't exactly know exactly which options are necessary and which options are not, according to the latest version of Sentry.

@kamilogorek
Copy link
Contributor

ExtraErrorData is used to extract additional, non-default properties from captured exception, eg:

const err = new Error('whoops');
err.randomNumber = 9;
Sentry.captureException(err);

this will attach randomNumber as part of the error context. It defaults to 3 levels of depth, so eg. err.someObj.nestedObj.randomNumber will be fine, but anything deeper would be truncated if not overridden.

normalizeDepth is the depth of a whole event captured. Because everything that ExtraErrorData attaches is nested within event.contexts, you need to set it to +1 of what you set your ExtraErrorData integration to.

@rchl
Copy link
Contributor

rchl commented Oct 8, 2021

@kamilogorek You've mentioned that you will update documentation with that info but https://docs.sentry.io/platforms/javascript/configuration/integrations/plugin/#extraerrordata still doesn't mention that normalizeDepth has to be updated also.

It took me a while to figure out why changing depth in ExtraErrorData doesn't let me see more of the captured data...

@kamilogorek
Copy link
Contributor

My bad, I thought I did it - getsentry/sentry-docs#4247

@rchl
Copy link
Contributor

rchl commented Oct 8, 2021

Thanks :)

@lobsterkatie
Copy link
Member

lobsterkatie commented Feb 11, 2022

This is in fact not fixed, but is on our list for our upcoming v7 major release. Reopening.

(Note to future self: Make sure this fix applies to __serialized__ as well. Also, see the PR below for an explanation of the underlying problem.)

#2404

@AbhiPrasad
Copy link
Member

Closed with #5052 and #5053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants