Skip to content

fix(integrations): Mark ExtraErrorData as already normalized #5053

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

Merged
merged 1 commit into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions packages/integrations/src/extraerrordata.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Event, EventHint, EventProcessor, ExtendedError, Hub, Integration } from '@sentry/types';
import { isError, isPlainObject, logger, normalize } from '@sentry/utils';
import { Contexts, Event, EventHint, EventProcessor, ExtendedError, Hub, Integration } from '@sentry/types';
import { addNonEnumerableProperty, isError, isPlainObject, logger, normalize } from '@sentry/utils';

import { IS_DEBUG_BUILD } from './flags';

Expand Down Expand Up @@ -53,23 +53,22 @@ export class ExtraErrorData implements Integration {
if (!hint || !hint.originalException || !isError(hint.originalException)) {
return event;
}
const name = (hint.originalException as ExtendedError).name || hint.originalException.constructor.name;
const exceptionName = (hint.originalException as ExtendedError).name || hint.originalException.constructor.name;

const errorData = this._extractErrorData(hint.originalException as ExtendedError);

if (errorData) {
let contexts = {
const contexts: Contexts = {
...event.contexts,
};

const normalizedErrorData = normalize(errorData, this._options.depth);

if (isPlainObject(normalizedErrorData)) {
contexts = {
...event.contexts,
[name]: {
...normalizedErrorData,
},
};
// We mark the error data as "already normalized" here, because we don't want other normalization procedures to
// potentially truncate the data we just already normalized, with a certain depth setting.
addNonEnumerableProperty(normalizedErrorData, '__sentry_skip_normalization__', true);
contexts[exceptionName] = normalizedErrorData;
}

return {
Expand Down