Skip to content
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

ignoreErrors ignores the wrong linked error #8079

Closed
lobsterkatie opened this issue May 9, 2023 · 2 comments · Fixed by #8089
Closed

ignoreErrors ignores the wrong linked error #8079

lobsterkatie opened this issue May 9, 2023 · 2 comments · Fixed by #8089

Comments

@lobsterkatie
Copy link
Member

In cases where there are linked errors, the event.exception.values array contains the errors in chronological order: first the cause error and then the main error:

image

and indeed, this is how they come through in the resulting JSON:

image

But in the UI, the order is reversed:

image

Also, it is the second error which shows up as the title:

image

This suggests that we should be filtering on the second error, since everything in the UI points to it being the "main" one. But for ignoreErrors, when we're getting the strings to compare against the ignored values, we take the first error, not the second:

const { type = '', value = '' } = (event.exception.values && event.exception.values[0]) || {};

Two options for fixing this:

  1. Take the last error instead of the first error. For any event with only one (which is most of them), the first and the last are the same, so nothing would change. For events with multiple errors, we'd be filtering on the right one, albeit a different one than we've been filtering on.
  2. Check all of the errors in event.exception.values. This has the advantage of being backwards compatible (errors which are currently being ignored will continue to be ignored), but might be less intuitive behavior.

I'm happy to make a PR for either solution. Which do y'all think is best?

(For context, this is coming up because we're trying to be better dogfooders of the SDK in the Sentry FE, and go through the process of de-noising our JS project. In order to do that, it'd be nice to be able to use ignoreErrors, but it doesn't currently filter in the way we need (and in the way, IMHO, it should).)

@Lms24
Copy link
Member

Lms24 commented May 9, 2023

Hey @lobsterkatie great to hear from you! :)

So we discussed this and and we just need some clarification around how these linked errors show up in Sentry. Can we assume that for an event with multiple errors (i.e. event.exception.values.length > 1) always only one Sentry issues is created?

Then I think we should go with option 1 and match the top error, i.e. the last one in the array. If this one matches, the entire event should be dropped. I think this is most the intuitive approach for users. Obviously this is "behaviourally" breaking but I think this can be justified as we're essentially fixing a bug.

In case our assumption doesn't hold up and multiple issues are created for such events (I think this is unlikely but just to be sure), we should iterate through the individual exceptions and only drop those that match entries in ignoreErrors.

Will bring this up at our Daily today, too.

@lobsterkatie
Copy link
Member Author

Yup - it only ever makes one event. Here is a real-life version and here is the event shown in the screenshots, which came from shoving the following

const err = createRequestError(
  {
    getResponseHeader: (_header: string) => null,
    responseJSON: '',
    responseText: 'hi',
    status: 401,
    statusText: 'nope',
  },
  new Error('this error is the cause'),
  'GET',
  '/dogs/are/great'
);
Sentry.captureException(err);

(which uses the helper defined here) into initializeSdk.tsx, right after our call to Sentry.init().

In any case, great, and thanks for the input. Filtering on the last/main error is the way I already did it in order to test stuff out, so I can put up a PR today.

Cheers!

@lobsterkatie lobsterkatie self-assigned this May 9, 2023
lobsterkatie added a commit that referenced this issue May 10, 2023
This fixes a helper function used in our implementation of `ignoreErrors` so that in the case of linked errors, it filters on the primary error (the one directly caught by `captureException`) rather than the error in the primary error's `cause` property[1]. See #8079 for screenshots and a more detailed explanation.

Fixes #8079.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error/cause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants