Skip to content

Relax enum validation in generated models to tolerate unknown/new API values #931

Description

@vdusek

Enum fields in the generated models are strict Literal[...] aliases (src/apify_client/_literals.py).
Since every API response is validated with Pydantic, any enum value the platform sends that the
(older) client doesn't know raises a ValidationError and the whole call fails.

This means every new backend enum value breaks clients in the wild until we regenerate and release.
See apify/apify-sdk-python#1032 (missing MCP origin) and the reactive patch #929.

Proposal: emit an open literal Literal[...] | str instead of bare Literal[...] in the
postprocess step (scripts/postprocess_generated_models.py), so unknown values validate while known
members stay as autocomplete hints.

Activity

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

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions