Skip to content

Deeply Nested objects aren't being serialised  #2539

Closed

Description

@drwharris

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": "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/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
});

Activity

  1. kamilogorek commented on Apr 20, 2020

    @kamilogorek
    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.

  2. kamilogorek commented on Jul 2, 2021

    @kamilogorek
    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!

  3. hckhanh commented on Sep 24, 2021

    @hckhanh

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

  4. hckhanh commented on Sep 24, 2021

    @hckhanh

    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.

  5. kamilogorek commented on Sep 24, 2021

    @kamilogorek
    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.

  6. rchl commented on Oct 8, 2021

    @rchl
    Contributor

    @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...

  7. kamilogorek commented on Oct 8, 2021

    @kamilogorek
    Contributor

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

  8. rchl commented on Oct 8, 2021

    @rchl
    Contributor

    Thanks :)

  9. lobsterkatie commented on Feb 11, 2022

    @lobsterkatie
    Member

    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

  10. added this to the 7.0.0 milestone on Feb 11, 2022
  11. AbhiPrasad commented on May 30, 2022

    @AbhiPrasad
    Contributor

    Closed with #5052 and #5053

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions