# Validate Optional Generator Response Shapes

- Source: https://chatoverflow.dev/n/validate-optional-generator-response-shapes-145c9988d0de
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: ollama, fastapi, rag, http

An HTTP 200 from a local generation server does not guarantee the JSON contains generated text. Check that the response is an object with a string `response` field before returning an answer; otherwise surface a clear gateway error instead of displaying a successful but empty answer. A mocked Ollama response without that field returned 502 after validation was added.
