{"record":{"id":"6e89e82e5a7a81f9","repo":"BerriAI/litellm","slug":"error-in-response-object-format-got-none-6e89e8","errorCode":null,"errorMessage":"Error in response object format, got None","messagePattern":"Error in response object format, got None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"litellm/llms/bedrock/image_generation/image_handler.py","lineNumber":324,"sourceCode":"        response: httpx.Response,\n        data: dict,\n    ) -> ImageResponse:\n        \"\"\"\n        Transforms the Image Generation response from Bedrock to OpenAI format\n        \"\"\"\n\n        ## LOGGING\n        if logging_obj is not None:\n            logging_obj.post_call(\n                input=prompt,\n                api_key=\"\",\n                original_response=response.text,\n                additional_args={\"complete_input_dict\": data},\n            )\n        verbose_logger.debug(\"raw model_response: %s\", response.text)\n        response_dict: Final = response.json()\n        if response_dict is None:\n            raise ValueError(\"Error in response object format, got None\")\n\n        config_class: Final = self.get_config_class(model=model)\n\n        config_class.transform_response_dict_to_openai_response(\n            model_response=model_response,\n            response_dict=response_dict,\n        )\n\n        return model_response\n","sourceCodeStart":306,"sourceCodeEnd":334,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_generation/image_handler.py#L306-L334","documentation":"After a successful HTTP response, litellm calls response.json() and checks the result: if parsing yields None (e.g. body was the literal string 'null' or an empty/invalid JSON body), it raises ValueError('Error in response object format, got None') before transforming to the OpenAI image response shape.","triggerScenarios":"Bedrock returning a 200 with an empty body or 'null' body — seen with some proxy setups, API gateways, or truncated responses — while model/response parsing expects a JSON object.","commonSituations":"Self-hosted proxies (LiteLLM proxy chains, nginx) stripping bodies, gateway timeouts returning empty 200s, or a provider bug returning null JSON for failed generations.","solutions":["Enable verbose logging (litellm.verbose = True or set litellm.set_verbose) and inspect 'raw model_response' to see what body actually arrived.","Bypass the proxy/intermediary and call Bedrock directly to confirm where the empty body originates.","Retry the request — empty 200 bodies are usually transient infrastructure faults.","If reproducible with a direct AWS call, report to litellm with the raw response; otherwise fix the intermediary (proxy timeouts, buffering)."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_generation(model=model, prompt=p)\nexcept ValueError as e:\n    if \"got None\" in str(e):\n        log.error(\"Empty/null body from Bedrock — retrying once\")\n        return litellm.image_generation(model=model, prompt=p)  # usually transient\n    raise","preventionTips":["Enable litellm verbose logging to capture the raw response text when this fires.","If behind a proxy, verify it does not truncate/empty 200 bodies.","Alert on frequency — recurring empty bodies indicate infra faults, not bad requests."],"tags":["bedrock","image-generation","response-parsing","json","proxy"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}