BerriAI/litellm · error · ValueError

Error in response object format, got None

Error message

Error in response object format, got None

What it means

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).

Source

Thrown at litellm/llms/bedrock/image_edit/handler.py:308

        response: httpx.Response,
        data: dict,
    ) -> ImageResponse:
        """
        Transforms the Image Edit response from Bedrock to OpenAI format
        """

        ## LOGGING
        if logging_obj is not None:
            logging_obj.post_call(
                input=prompt,
                api_key="",
                original_response=response.text,
                additional_args={"complete_input_dict": data},
            )
        verbose_logger.debug("raw model_response: %s", response.text)
        response_dict: Final = response.json()
        if response_dict is None:
            raise ValueError("Error in response object format, got None")

        config_class: Final = self.get_config_class(model=model)
        config_instance: Final = config_class()

        model_response = config_instance.transform_image_edit_response(
            model=model,
            raw_response=response,
            logging_obj=logging_obj,
        )

        return model_response

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Retry the request — a null/empty 2xx body from InvokeModel is not a deterministic client error.
  2. 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.
  3. Report to litellm/AWS with the request id if it persists in one region.
Defensive patterns

Strategy: retry

Try / catch

try:
    resp = litellm.image_edit(model=m, image=img, prompt=p)
except ValueError as e:
    if "got None" in str(e):
        resp = litellm.image_edit(model=m, image=img, prompt=p)  # one retry
    else:
        raise

Prevention

When it happens

Trigger: 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'.

Common situations: A gateway between client and Bedrock rewriting responses; degraded Bedrock endpoints; tests mocking responses with json().return_value = None.

Related errors


AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15). Data as JSON: /api/errors/1c54cb00e93a4753. Report an issue: GitHub.