Visitar URL original
Response validation raises a raw pydantic `ValidationError` that is not an `ApifyClientError` · Issue #1170 · apify/apify-client-python · GitHub
Skip to content

Response validation raises a raw pydantic ValidationError that is not an ApifyClientError #1170

Open

Description

@vdusek

Resource methods turn API responses into models with <Model>.model_validate(...), for example ActorClient.get. There are about 160 such calls and none of them catches the error, so a response that does not match the model raises pydantic.ValidationError. That class does not inherit from ApifyClientError, so except ApifyClientError does not catch it, and the message says nothing about which request failed. The only place that catches it is UserClient.get (#L60-L65, #L183-L188), where it is used to pick between the private and public user model.

This is what users saw in #811, #822 and #829: after an API or spec drift, client.actor(...).get() and .call() failed with "N validation errors for ActorResponse", and code that guards client calls with except ApifyClientError crashed.

The JS client wraps schema failures in ResponseValidationError, a subclass of ApifyClientError. parseResponse (utils.ts#L116-L128) raises it with the request method and URL, the structured issues, and the original zod error as cause, plus a hint asking the user to report the mismatch.

Expected behavior

Validate responses through one helper that catches pydantic.ValidationError and raises a ResponseValidationError(ApifyClientError, ValueError) carrying the HTTP method, the URL, errors() from pydantic, and the original exception as __cause__. UserClient.get keeps catching the raw error internally for its private/public fallback.

✍️ Drafted by Claude Code

Activity

  1. added this to the 4.0 milestone on Oct 30, 2026
  2. added
    bugSomething isn't working.
    t-toolingIssues with this label are in the ownership of the tooling team.
    on Oct 30, 2026
  3. added theissue type on Oct 30, 2026
  4. removed
    bugSomething isn't working.
    on Oct 30, 2026
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

    t-toolingIssues with this label are in the ownership of the tooling team.

    Type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions