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

Aperta Adatta ai principianti
#25,920 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@rjmcgee53192 ci sta già lavorando.

Dal 30/10/2026.

  • #25967 di @rjmcgee53192 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
78/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
javascript, node.js, typescript
Ambito
backend, testing

Direzione di ricerca

Leggi packages/core/src/utils/normalize.ts, concentrandoti sui blocchi catch di normalize e stringifyValue. Riproduci il problema con i tre esempi di getter nell’issue e verifica se i valori intercettati che sono Symbols o oggetti senza prototipo continuano a propagarsi come eccezioni. Il lavoro è terminato quando tutti i casi restituiscono un marcatore non serializzabile senza generare eccezioni.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.

Lingua principale
TypeScript
Stelle
8.8k
Fork
1.9k
Merge medio
1g 19h
PR unite (30g)
664

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di getsentry/sentry-javascript

Tutte le issue di getsentry/sentry-javascript

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.