Skip to content

confused error return message #44

Description

@FelixSeptem

I use async_send method, and return the error below. Look like missing some args in response, maybe return more readable error message?

[02-05 07:08:40 - LOGID:8db00a95-591 - openrouter - 229 - ERROR] OpenRouterLLMService (SDK) error: Response validation failed: 4 validation errors for Unmarshaller
body.id
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.choices
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.created
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.model
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
Traceback (most recent call last):
File "/opt/app/agent-core/.venv/lib/python3.11/site-packages/openrouter/utils/unmarshal_json_response.py", line 31, in unmarshal_json_response
return unmarshal_json(body, typ)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/app/agent-core/.venv/lib/python3.11/site-packages/openrouter/utils/serializers.py", line 140, in unmarshal_json
return unmarshal(from_json(raw), typ)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/app/agent-core/.venv/lib/python3.11/site-packages/openrouter/utils/serializers.py", line 150, in unmarshal
m = unmarshaller(body=val)
^^^^^^^^^^^^^^^^^^^^^^
File "/opt/app/agent-core/.venv/lib/python3.11/site-packages/pydantic/main.py", line 250, in init
validated_self = self.pydantic_validator.validate_python(data, self_instance=self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
pydantic_core._pydantic_core.ValidationError: 4 validation errors for Unmarshaller
body.id
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.choices
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.created
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.model
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/app/agent-core/app/services/llm/providers/openrouter.py", line 209, in generate_response
response = await client.chat.send_async(**params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/app/agent-core/.venv/lib/python3.11/site-packages/openrouter/chat.py", line 931, in send_async
return unmarshal_json_response(
^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/app/agent-core/.venv/lib/python3.11/site-packages/openrouter/utils/unmarshal_json_response.py", line 33, in unmarshal_json_response
raise errors.ResponseValidationError(
openrouter.errors.responsevalidationerror.ResponseValidationError: Response validation failed: 4 validation errors for Unmarshaller
body.id
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.choices
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.created
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing
body.model
Field required [type=missing, input_value={'error': {'message': 'Pr...31rvMey1mEnpCcH3QmBDtR'}, input_type=dict]
For further information visit https://errors.pydantic.dev/2.12/v/missing

Activity

  1. kirirururu commented on Feb 15, 2026

    @kirirururu

    I have the same issue. I use SDK (chat completion) to generate images using Seedream 4.5 model. If provider returns 400 (and, probably, other 4XX) error (for example, if sensitive content detected), I get ResponseValidationError exception raised:

    Response validation failed: 4 validation errors for Unmarshaller
    body.id
      Field required [type=missing, input_value={'error': {'message': 'Pr...giDX9mRqO0uhNo5qPCbXYj'}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.11/v/missing
    body.choices
      Field required [type=missing, input_value={'error': {'message': 'Pr...giDX9mRqO0uhNo5qPCbXYj'}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.11/v/missing
    body.created
      Field required [type=missing, input_value={'error': {'message': 'Pr...giDX9mRqO0uhNo5qPCbXYj'}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.11/v/missing
    body.model
      Field required [type=missing, input_value={'error': {'message': 'Pr...giDX9mRqO0uhNo5qPCbXYj'}, input_type=dict]
        For further information visit https://errors.pydantic.dev/2.11/v/missing
    

    Here is the result of e.body.lstrip():

    {"error":{"message":"Provider returned error","code":400,"metadata":{"raw":"{\"error\":{\"code\":\"OutputImageSensitiveContentDetected\",\"message\":\"The request failed because the output image may contain sensitive information...\",\"param\":\"\",\"type\":\"\"}}","provider_name":"Seed","is_byok":false}},"user_id":"user_...giDX9mRqO0uhNo5qPCbXYj"}

    Seems like SDK tries to parse this response as success response, not as error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions