Skip to content

[Bug]: Pydantic models with overridden Config fail to parse with extra=ignore #3066

@r4victor

Description

@r4victor

It turns out that overriding Config in pydantic models breaks pydantic-duality extra=ignore parsing since Config overrides both Model.__request__.Config and Model.__response__.Config. As a result, adding new fields to models with custom Config leads to old client / new server incompatibility (and many models define custom schema_extra).

pydantic-duality supports defining common Config for all models via generate_dual_base_model(Config). As we want to also have a CoreModel with common config and methods, the fix would involve generating a custom base core model with custom config on the fly for every model that needs custom config:

class _BaseRunConfigurationConfig(CoreModel.Config):
        @staticmethod
        def schema_extra(schema: Dict[str, Any]):
            ...

class BaseRunConfiguration(generate_dual_core_model(_BaseRunConfigurationConfig)):
   ...

The inheritance approach should also be reworked so that mixin models do not inherit from CoreModel.

Metadata

Metadata

Assignees

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