{"record":{"id":"1c54cb00e93a4753","repo":"BerriAI/litellm","slug":"error-in-response-object-format-got-none","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_edit/handler.py","lineNumber":308,"sourceCode":"        response: httpx.Response,\n        data: dict,\n    ) -> ImageResponse:\n        \"\"\"\n        Transforms the Image Edit 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        config_instance: Final = config_class()\n\n        model_response = config_instance.transform_image_edit_response(\n            model=model,\n            raw_response=response,\n            logging_obj=logging_obj,\n        )\n\n        return model_response\n","sourceCodeStart":290,"sourceCodeEnd":320,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/bedrock/image_edit/handler.py#L290-L320","documentation":"After a successful Bedrock image-edit HTTP response, the handler parses response.json() and guards against a falsy parse result: if response_dict is None it raises ValueError('Error in response object format, got None'). This is a defensive check for a 2xx body that is not valid JSON object data (e.g. empty body or JSON null).","triggerScenarios":"Bedrock returns 200 with empty body or literal 'null' — rare, but observed with some proxy/intermediary (corporate proxy returning 200 with empty content) or truncated responses; response.json() on an empty body raises JSONDecodeError in httpx, so None most plausibly arises from a body of exactly 'null'.","commonSituations":"A gateway between client and Bedrock rewriting responses; degraded Bedrock endpoints; tests mocking responses with json().return_value = None.","solutions":["Retry the request — a null/empty 2xx body from InvokeModel is not a deterministic client error.","If reproducible, capture the raw response (enable verbose logging; the handler logs 'raw model_response: %s' via verbose_logger.debug) and check intermediaries (proxy, service mesh) that may alter bodies.","Report to litellm/AWS with the request id if it persists in one region."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    resp = litellm.image_edit(model=m, image=img, prompt=p)\nexcept ValueError as e:\n    if \"got None\" in str(e):\n        resp = litellm.image_edit(model=m, image=img, prompt=p)  # one retry\n    else:\n        raise","preventionTips":["Enable verbose logging to capture the raw response body when this fires.","Check for intermediary proxies that may rewrite 2xx bodies.","Treat a null-body 200 as transient; escalate only if it repeats in one region."],"tags":["bedrock","image-edit","response-parsing","defensive"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}