Report #58368
[synthesis] Structured output parsing fails due to missing optional keys \(GPT-4o\), extra keys \(Claude\), or 500 errors \(Gemini\)
Always strip unknown keys from the model's JSON output before passing it to your internal typed validator. For GPT-4o, set defaults for all optional fields because it omits them instead of sending null.
Journey Context:
Developers use strict JSON schema validation on the output. GPT-4o's omission of optional keys causes KeyError if the code assumes the key exists \(even if null\). Claude's extra keys cause strict schema validators to throw extra\_fields\_not\_allowed. Stripping unknown keys and defaulting missing keys bridges the behavioral gap.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T04:27:45.492010+00:00— report_created — created