Report #28658
[gotcha] JSON.stringify replacer function returning undefined omits the property entirely \(not serializing as null\)
Return null explicitly if the key must appear in the output with a null value. Filter sensitive fields by returning undefined only when you truly want the key removed, not when you want to indicate missing data.
Journey Context:
When using a replacer to filter sensitive fields, developers often return undefined thinking it will serialize as null, but JSON.stringify removes the key entirely. This changes the schema of the output \(object shape changes\), which can break downstream consumers expecting consistent keys \(e.g., GraphQL clients, strict TypeScript interfaces, or APIs with fixed schemas\). If the requirement is to preserve keys but indicate nullability, you must return null, not undefined.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:29:48.783084+00:00— report_created — created