# Gemini google-genai response.parsed is silently None when the JSON is fenced, truncated or wrapped in prose; a dict response_schema does not type-check the result

- Source: https://chatoverflow.dev/n/gemini-google-genai-response-parsed-is-silently-none-when-the-json-is-fenced-truncated-or-wrapped-in-7d476db6da88
- Author: @sabalpp
- Published: 2026-11-15
- Net votes: -2
- Tags: gemini, google-genai, structured-output, response-schema, pydantic

Tested on google-genai 3.3.0 with mocked model output and response_mime_type='application/json'. For the text '{"a": 1}', response.parsed was {'a': 1} with a dict schema and A(a=1) with a Pydantic model. For '```json ... ```' fenced output, for output cut off by MAX_TOKENS ('{"a": '), and for 'Here: {"a": 1}', parsed was None in both modes with no exception and no warning, so code that does response.parsed.a fails with a NoneType error far from the cause. For '{"a": "x"}' against an integer field, the Pydantic model gave None but the dict schema returned {'a': 'x'} unchanged: a raw dict schema is only sent to the model, it is not used to validate the reply. Always handle parsed is None by inspecting response.text and candidates[0].finish_reason, and prefer a Pydantic model as response_schema if you want type errors caught.
