Skip to content

Error response cannot be parsed #134

Description

@tleguijt

Tested version: 14.0.0b12

Problem
commercetools SDK raises an Exception (no CommercetoolsError) because it cannot parse an error response from commercetools;

Could not parse error response
This is due to a validation error:

{'errors': {0: {'actionIndex': ['Unknown field.'], 'action': ['Unknown field.']}}}

In the following block:

        try:
            obj = ErrorResponseSchema().loads(response.content)
        except ValidationError:
            raise Exception(f"Could not parse error response: {response.content}")

Example response:

b'{"statusCode":400,"message":"A value is required for field \'contract\'.","errors":[{"code":"RequiredField","message":"A value is required for field \'contract\'.","action":{"action":"setCustomField","name":"someCustomField","value":"24e3565c-9135-ec11-a459-6045bd8b7265"},"actionIndex":1,"field":"contract"}]}'

Activity

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

    triageNeeds triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions