Skip to content

Deeply Nested objects aren't being serialised #1964

Closed

Description

@drwharris

Important Details

I have a Node JS 11.9 application

  • On-Premise docker [Version xyz]
  • Saas (sentry.io)
  • Other AWS Fargate

Description

Just upgraded the package to "@sentry/node": "^4.6.5" from "@sentry/node": "^4.5.4".

When adding objects to Addition Data I would see the following logged:

{
	ExMessage: ,
	level: error,
	Payload: {
		AcquisitionId: ,
		ClientId: ,
		DeviceData: {  <<  - Note this 
			Browser: {
				major: ,
				name: ,
				version:
			},
			Cpu: {},
			Device: {
				type:
			},
			Engine: {
				name: ,
				version:
			},
			Os: {
				name: ,
				version:
			}
		},
		Environment: ,
		EventDate: {},  <<  - Note this 
		Fingerprint: ,
		Geographical: {}, <<  - Note this 
		IpAddress: ,
		Referer: ,
		Sequence: ,
		SessionId: ,
		Type: ,
		Url: ,
		UserAgent: ,
		UserName: ,
		Version: ,
		Weather: {} <<  - Note this
	}
}

Unfortunately, now after upgrading I am getting:

{
	ExMessage: ,
	level: ,
	Payload: {
		AcquisitionId: ,
		ClientId: ,
		DeviceData: [Object],  <<- Note this
		Environment: ,
		EventDate: [Object],  <<- Note this
		Fingerprint: ,
		Geographical: [Object],  <<- Note this
		IpAddress: ,
		Referer: ,
		Sequence: ,
		SessionId: ,
		Type: ,
		Url: ,
		UserAgent: ,
		UserName: ,
		Version: ,
		Weather: [Object] <<- Note this
	}
}

Steps to Reproduce

I have this class

export class TrackerError extends Error {
	Payload: any;
	ExMessage: string;
	constructor(message: string, err: Error, payload: any) {
		super(message);
		if (err) {
			this.stack = this.stack
				.split("\n")
				.slice(0, 2)
				.join("\n") +
				"\n" +
				err.stack;
			this.ExMessage = err.message;
		} else {
			Error.captureStackTrace(this, this.constructor);
		}

		if (payload) {
			this.Payload = payload;
		}
	}
}

which I then use as follows:

Sentry.captureException(new TrackerError("My Error Message", myErrObj, myPayloadObj));

What you expected to happen

As per previous versions, deep objects should be logged in detail

Activity

  1. HazAT commented on Mar 28, 2019

    @HazAT
    Member

    You should be able to define the depth yourself:

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

    We reduced the limit drastically since it caused many problems for users.
    Hope this helps.

  2. drwharris commented on Mar 28, 2019

    @drwharris
    Author

    @HazAT
    Where is this documented? And is this specific to the JS library?

  3. HazAT commented on Mar 28, 2019

    @HazAT
    Member

    TBH, this is sadly poorly documented and should be here:
    https://docs.sentry.io/platforms/javascript/default-integrations/#extraerrordata

    I will write this down to improve, and yes, this is JS specific.

  4. drwharris commented on Apr 1, 2019

    @drwharris
    Author

    OK Thank you.

  5. drwharris commented on Jun 11, 2019

    @drwharris
    Author

    Sorry to come back to this but I have just updated to 5.4.0 and its now erroring with:

    Property 'ExtraErrorData' does not exist on type '{ Console: typeof Console; Http: typeof Http; OnUncaughtException: typeof OnUncaughtException; OnUnhandledRejection: typeof OnUnhandledRejection; LinkedErrors: typeof LinkedErrors; Modules: typeof Modules; FunctionToString: typeof FunctionToString; InboundFilters: typeof InboundFilters; }'.

    21 integrations: [new Sentry.Integrations.ExtraErrorData({ depth: 10 })]

  6. kamilogorek commented on Jun 12, 2019

    @kamilogorek
    Contributor

    @drwharris

    import { ExtraErrorData } from '@sentry/integrations';
  7. drwharris commented on Apr 9, 2020

    @drwharris
    Author

    This seems to have regressed. I have this:

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

    And I get this

    {
    	AcquisitionId: "",
    	ClientId: "",
    	DeviceData: [Object], <<- Note this
    	Environment: "",
    	EventDate: [Object], <<- Note this
    	Fingerprint: "",
    	Geographical: [Object], <<- Note this
    	IpAddress: "",
    	Referer: "", 
    	Sequence: "", 
    	SessionId: "", 
    	Type: "", 
    	Url: "", 
    	UserAgent: "", 
    	UserName: "", 
    	Version: ""
    }
    
    
  8. mcastets commented on May 7, 2020

    @mcastets

    You need to use the undocumented new param normalizeDepth and set it to normalizeDepth: depth + 1 :

    In your example:

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

    See also: #2404

  9. gr2m commented on Sep 7, 2020

    @gr2m

    I've run into the same problem and can confirm that adding normalizeDepth resolves the problem. I also double checked if integrations: [new ExtraErrorData({ depth: 10 })], is necessary at all and it turns out it is not, removing it results in the same output on Sentry.

    The option was add in #2404 (shipped in v5.12.0), but I could not find any documentation

  10. kamilogorek commented on Sep 14, 2020

    @kamilogorek
    Contributor

    We are aware of this issue - #2539 (comment)
    It will be fixed in v6, as it's breaking change.

  11. FabienCH commented on Sep 30, 2020

    @FabienCH

    Hello,

    I have an issue that might be related and that I can not get to work. Just to be sure, [new ExtraErrorData({ depth: 10 })] is supposed to modify ADDITIONAL DATA field depth in the error report right ?

    If so, I am using Sentry 5.22.1 and it doesn't seems to work:

     Sentry.init({
          dsn: 'https://mydsn',
          integrations: [new ExtraErrorData({ depth: 9 })],
          normalizeDepth: 10,
        });

    And the additional data __serialized__ object looks loke this:

    {
      error: {
        errors: {
          Views: [Array]
        }, 
        status: 400, 
        ...
      },
      ...
    } 
  12. kamilogorek commented on Sep 30, 2020

    @kamilogorek
    Contributor

    I just verified it locally and it works just fine for me:

    image

    Sentry.init({
      dsn: "__public_dsn__",
      integrations: [new Sentry.Integrations.ExtraErrorData({ depth: 9 })],
      normalizeDepth: 10,
      beforeSend(event) {
        console.log(event);
        return null;
      },
    });
    
    const err = new Error("foo");
    err.some = {
      additional: {
        data: [{ foo: { bar: 123 } }],
      },
    };
    
    Sentry.captureException(err);
  13. FabienCH commented on Sep 30, 2020

    @FabienCH

    Ok, thank you for your reply, I'll try to figure out where my problem comes from.

  14. lcaballero99 commented on Sep 15, 2021

    @lcaballero99

    I work only with normalizeDepth: 11

    Sentry.init({ dsn: process.env.SENTRYDSN, debug: true, environment: process.env.NODE_ENV, enabled: process.env.SENTRY === 'true', logLevel: 1, integrations: [ new Sentry.Integrations.Http({ tracing: true }), ], normalizeDepth: 11, });

  15. lobsterkatie commented on Feb 11, 2022

    @lobsterkatie
    Member

    Duplicate of #2539

  16. captbilard commented on Aug 21, 2023

    @captbilard

    I work only with normalizeDepth: 11

    Sentry.init({ dsn: process.env.SENTRYDSN, debug: true, environment: process.env.NODE_ENV, enabled: process.env.SENTRY === 'true', logLevel: 1, integrations: [ new Sentry.Integrations.Http({ tracing: true }), ], normalizeDepth: 11, });

    Same here, adding only normalizeDepth worked for me

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

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions