Skip to content

fix(core): stop normalize() from throwing on symbol and null-prototype errors - #25967

Draft
rjmcgee53192 wants to merge 1 commit into
getsentry:developfrom
rjmcgee53192:contrib/fix-25920
Draft

rjmcgee53192 wants to merge 1 commit into
getsentry:developfrom
rjmcgee53192:contrib/fix-25920

Conversation

@rjmcgee53192

Copy link
Copy Markdown

Why: normalize() is documented to always return a value, using the **non-serializable** marker when something goes wrong — but it could throw itself. Both places that build that marker interpolated the caught value into a template literal, and that conversion throws for a symbol (Cannot convert a Symbol value to a string) and for an object with no usable toString. A property getter throwing either one is enough to make normalize() throw during event preparation. The caught value is now converted with String() inside a try/catch, falling back to fixed text, so callers only ever get the marker.

How to review: One small helper in packages/core/src/utils/normalize.ts, used by the two catch blocks there. The new tests in normalize.test.ts cover a getter throwing a symbol, a getter throwing a null-prototype object, and the stringifyValue catch failing with a symbol. I verified the fix by running the issue's reproduction against the source directly (both cases threw before, both return the marker after, ordinary inputs unchanged). I could not complete a full local pnpm install in my environment, so CI will be the first full suite run — flagging that honestly rather than claiming a green local run.

Unsure about: Opening this as a draft without a prior maintainer go-ahead on the issue — happy to adjust the approach if you'd rather handle it differently.

Closes #25920

…e errors

normalize() built its **non-serializable** marker by interpolating the
caught value into a template literal. That conversion throws for a
symbol and for an object with no usable toString, so a property getter
throwing either one made normalize() throw instead of returning the
marker its docs promise.

Convert the caught value with String() inside a try/catch and fall
back to fixed text when even that throws. Covers both catch blocks in
normalize.ts (normalize and stringifyValue) and adds regression tests
for a getter throwing a symbol, a getter throwing a null-prototype
object, and stringifyValue failing with a symbol.

Fixes getsentry#25920
@github-actions github-actions Bot added the external PR from an external contributor label Oct 30, 2026

This branch has not been deployed

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

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

normalize() throws when a getter throws a Symbol or a null-prototype object

1 participant