Skip to content

fix(core): Use maxValueLength in extra error data integration #12174

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 3 commits into from
Jun 19, 2024

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented May 22, 2024

fixes #12168

We should truncate extra error data keys using maxValueLength to make sure event payload size stays reasonably small.

@AbhiPrasad AbhiPrasad requested review from a team, mydea and andreiborza and removed request for a team May 22, 2024 18:00
@AbhiPrasad AbhiPrasad self-assigned this May 22, 2024
@@ -97,7 +103,7 @@ function _extractErrorData(error: ExtendedError, captureErrorCause: boolean): Re
continue;
}
const value = error[key];
extraErrorInfo[key] = isError(value) ? value.toString() : value;
extraErrorInfo[key] = truncate(isError(value) ? value.toString() : value, maxValueLength);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually now that I'm looking at this again, const value = error[key] means that value could be anything. What is the cleanest way here to make sure we truncate all the string? Should I adjust the normalize function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can just do something like this:

Suggested change
extraErrorInfo[key] = truncate(isError(value) ? value.toString() : value, maxValueLength);
extraErrorInfo[key] = isError(value) || typeof value === 'string' ? truncate(`${value}`, maxValueLength) : value;

?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue here is that it'll only truncate string values at the top-most level. String values that are nested within an object will not get truncated.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm I see. Yeah then if we want to fix this I guess we have to update normalize to also handle max value length!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given the normalize update will mean refactoring how base client and event processing works, I'm electing for the quick fix and just using your change on the extraErrorInfo[key] setter. This also unblocks the user.

I will create a GH issue and write down what we need to do to make a more robust fix.

@WesCossick
Copy link

Any update on this? We're starting to retroactively discover more and more lost errors that our engineering team needs to be aware of due to this bug.

@AbhiPrasad
Copy link
Member Author

Hi @WesCossick sorry for the delay - there were some other items that took my attention away from this recently. I will try to get to this tomorrow and release by next week.

The source of the problems are the extraErrorDataIntegration integration. For now I recommend removing this integration to make sure you get no errors dropped.

As another workaround, you can make sure that the fields set by extraErrorDataIntegration on the sentry event are trimmed accordingly via the beforeSend option in Sentry.init.

@AbhiPrasad AbhiPrasad force-pushed the abhi-extraerrordata-max-length branch from 1bdace8 to 6cca211 Compare June 17, 2024 14:26
@mydea mydea merged commit 2fbd7cc into develop Jun 19, 2024
113 checks passed
@mydea mydea deleted the abhi-extraerrordata-max-length branch June 19, 2024 09:17
@lforst
Copy link
Contributor

lforst commented Jun 19, 2024

Am I dumb or could we use our normalizeToSize() function to truncate the extra data to a sane length?

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

Successfully merging this pull request may close these issues.

extraErrorDataIntegration leads to large events
4 participants