Skip to content

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

Closed

Description

@shi-rudo

Is there an existing issue for this?

How do you use Sentry?

Not applicable. The reproduction calls normalize from @sentry/core directly, without a DSN.

Which SDK are you using?

@sentry/core (the normalize utility that every SDK uses)

SDK Version

11.10.0

Steps to Reproduce

Node.js 24.21.0:

const { normalize } = require('@sentry/core')

const throwsError = { get x() { throw new Error('getter failed') } }
const throwsSymbol = { get x() { throw Symbol('s') } }
const throwsNullProto = { get x() { throw Object.create(null) } }

normalize({ bad: throwsError }, 3)
normalize({ bad: throwsSymbol }, 3)
normalize({ bad: throwsNullProto }, 3)

Expected Result

normalize returns the **non-serializable** marker for all three, as its JSDoc states: "returns A normalized version of the object, or "**non-serializable**" if any errors are thrown during normalization."

Actual Result

{ ERROR: '**non-serializable** (Error: getter failed)' }
TypeError: Cannot convert a Symbol value to a string
TypeError: Cannot convert object to primitive value

The second and third calls throw out of normalize.

Additional Context

Both catch blocks in packages/core/src/utils/normalize.ts (in normalize and in stringifyValue) build the marker with a template literal, `**non-serializable** (${err})`. The template literal converts the caught value to a string. That conversion throws for a Symbol and for an object without a usable toString or Symbol.toPrimitive. The current develop branch has the same code. A conversion that cannot throw, with a fixed fallback text, would keep normalize total.

Activity

  1. linear-code commented on Oct 29, 2026

    @linear-code
  2. lazerg commented on Oct 30, 2026

    @lazerg
    Contributor

    I want to work on it.

  3. added a commit that references this issue on Oct 30, 2026
    6c65c85
  4. self-assigned this
    on Nov 6, 2026
  5. added a commit that references this issue on Nov 6, 2026
    593e565
  6. added a commit that references this issue on Nov 9, 2026
    4cdb08c
  7. github-actions commented on Nov 10, 2026

    @github-actions
    Contributor

    A PR closing this issue has just been released 🚀

    This issue was referenced by PR #25967, which was included in the 11.12.0 release.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions