Skip to content

Conversation

@mc-dorzo
Copy link
Contributor

Pydantic v2 treats 'model_config' as a reserved name for configuration. This caused runtime errors during dynamic model creation. Renamed the field to maintain compatibility.

Pydantic v2 treats 'model_config' as a reserved name for configuration.
This caused runtime errors during dynamic model creation.
Renamed the field to maintain compatibility.
@commonism
Copy link
Owner

Hi,

as this has been working fine for … quite some time, can you get me the versions

python3 -c "import pydantic.version; print(pydantic.version.version_info()); import aiopenapi3; print(aiopenapi3.__version__)"

and an MRE to look at?

@codecov
Copy link

codecov bot commented Apr 11, 2025

Codecov Report

Attention: Patch coverage is 82.22222% with 8 lines in your changes missing coverage. Please review.

Project coverage is 94.61%. Comparing base (de0c311) to head (9415cae).
Report is 15 commits behind head on master.

Files with missing lines Patch % Lines
aiopenapi3/pydanticv2.py 78.94% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #348      +/-   ##
==========================================
- Coverage   94.80%   94.61%   -0.19%     
==========================================
  Files          88       88              
  Lines        7468     7507      +39     
==========================================
+ Hits         7080     7103      +23     
- Misses        388      404      +16     
Flag Coverage Δ
core 94.61% <82.22%> (-0.19%) ⬇️
extras 94.61% <82.22%> (-0.19%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mc-dorzo
Copy link
Contributor Author

mc-dorzo commented Apr 11, 2025

Hey @commonism, I’ve been working with these packages for over 6 months. I may have recently upgraded FastAPI or another dependency, but suddenly I started getting the errors I addressed in this fix — and it happens with any openapi.json I’m provided.

versions are

pydantic version: 2.11.1
pydantic-core version: 2.33.0
pydantic-core build: profile=release pgo=false
install path: /home/vscode/.cache/pypoetry/virtualenvs/parlant-sN1v-GXZ-py3.10/lib/python3.10/site-packages/pydantic
python version: 3.10.16 (main, Mar 19 2025, 16:47:00) [GCC 13.2.0]
platform: Linux-6.10.14-linuxkit-aarch64-with-glibc2.39
related packages: fastapi-0.115.12 typing_extensions-4.13.0 mypy-1.15.0

example of json:

{
    "openapi": "3.1.0",
    "info":
    {
        "title": "FastAPI",
        "version": "0.1.0"
    },
    "servers":
    [
        {
            "url": "http://localhost:8092"
        }
    ],
    "paths":
    {
        "/one_required_query_param":
        {
            "get":
            {
                "summary": "One Required Query Param",
                "operationId": "one_required_query_param",
                "parameters":
                [
                    {
                        "name": "query_param",
                        "in": "query",
                        "required": true,
                        "schema":
                        {
                            "type": "integer",
                            "title": "Query Param"
                        }
                    }
                ],
                "responses":
                {
                    "200":
                    {
                        "description": "Successful Response",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {}
                            }
                        }
                    },
                    "422":
                    {
                        "description": "Validation Error",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/two_required_query_params":
        {
            "get":
            {
                "summary": "Two Required Query Params",
                "operationId": "two_required_query_params",
                "parameters":
                [
                    {
                        "name": "query_param_1",
                        "in": "query",
                        "required": true,
                        "schema":
                        {
                            "type": "integer",
                            "title": "Query Param 1"
                        }
                    },
                    {
                        "name": "query_param_2",
                        "in": "query",
                        "required": true,
                        "schema":
                        {
                            "type": "integer",
                            "title": "Query Param 2"
                        }
                    }
                ],
                "responses":
                {
                    "200":
                    {
                        "description": "Successful Response",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {}
                            }
                        }
                    },
                    "422":
                    {
                        "description": "Validation Error",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/one_required_body_param":
        {
            "post":
            {
                "summary": "One Required Body Param",
                "operationId": "one_required_body_param",
                "requestBody":
                {
                    "content":
                    {
                        "application/json":
                        {
                            "schema":
                            {
                                "$ref": "#/components/schemas/OneBodyParam"
                            }
                        }
                    },
                    "required": true
                },
                "responses":
                {
                    "200":
                    {
                        "description": "Successful Response",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {}
                            }
                        }
                    },
                    "422":
                    {
                        "description": "Validation Error",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/two_required_body_params":
        {
            "post":
            {
                "summary": "Two Required Body Params",
                "operationId": "two_required_body_params",
                "requestBody":
                {
                    "content":
                    {
                        "application/json":
                        {
                            "schema":
                            {
                                "$ref": "#/components/schemas/TwoBodyParams"
                            }
                        }
                    },
                    "required": true
                },
                "responses":
                {
                    "200":
                    {
                        "description": "Successful Response",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {}
                            }
                        }
                    },
                    "422":
                    {
                        "description": "Validation Error",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/one_required_query_param_one_required_body_param":
        {
            "post":
            {
                "summary": "One Required Query Param One Required Body Param",
                "operationId": "one_required_query_param_one_required_body_param",
                "parameters":
                [
                    {
                        "name": "query_param",
                        "in": "query",
                        "required": true,
                        "schema":
                        {
                            "type": "integer",
                            "title": "Query Param"
                        }
                    }
                ],
                "requestBody":
                {
                    "required": true,
                    "content":
                    {
                        "application/json":
                        {
                            "schema":
                            {
                                "$ref": "#/components/schemas/OneBodyParam"
                            }
                        }
                    }
                },
                "responses":
                {
                    "200":
                    {
                        "description": "Successful Response",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {}
                            }
                        }
                    },
                    "422":
                    {
                        "description": "Validation Error",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        },
        "/dto_object":
        {
            "get":
            {
                "summary": "Dto Object",
                "operationId": "dto_object",
                "requestBody":
                {
                    "content":
                    {
                        "application/json":
                        {
                            "schema":
                            {
                                "$ref": "#/components/schemas/DummyDTO"
                            }
                        }
                    },
                    "required": true
                },
                "responses":
                {
                    "200":
                    {
                        "description": "Successful Response",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {}
                            }
                        }
                    },
                    "422":
                    {
                        "description": "Validation Error",
                        "content":
                        {
                            "application/json":
                            {
                                "schema":
                                {
                                    "$ref": "#/components/schemas/HTTPValidationError"
                                }
                            }
                        }
                    }
                }
            }
        }
    },
    "components":
    {
        "schemas":
        {
            "DummyDTO":
            {
                "properties":
                {
                    "number":
                    {
                        "type": "integer",
                        "title": "Number"
                    },
                    "text":
                    {
                        "type": "string",
                        "title": "Text"
                    }
                },
                "type": "object",
                "required":
                [
                    "number",
                    "text"
                ],
                "title": "Dummy"
            },
            "HTTPValidationError":
            {
                "properties":
                {
                    "detail":
                    {
                        "items":
                        {
                            "$ref": "#/components/schemas/ValidationError"
                        },
                        "type": "array",
                        "title": "Detail"
                    }
                },
                "type": "object",
                "title": "HTTPValidationError"
            },
            "OneBodyParam":
            {
                "properties":
                {
                    "body_param":
                    {
                        "type": "string",
                        "title": "Body Param"
                    }
                },
                "type": "object",
                "required":
                [
                    "body_param"
                ],
                "title": "OneBodyParam"
            },
            "TwoBodyParams":
            {
                "properties":
                {
                    "body_param_1":
                    {
                        "type": "string",
                        "title": "Body Param 1"
                    },
                    "body_param_2":
                    {
                        "type": "string",
                        "title": "Body Param 2"
                    }
                },
                "type": "object",
                "required":
                [
                    "body_param_1",
                    "body_param_2"
                ],
                "title": "TwoBodyParams"
            },
            "ValidationError":
            {
                "properties":
                {
                    "loc":
                    {
                        "items":
                        {
                            "anyOf":
                            [
                                {
                                    "type": "string"
                                },
                                {
                                    "type": "integer"
                                }
                            ]
                        },
                        "type": "array",
                        "title": "Location"
                    },
                    "msg":
                    {
                        "type": "string",
                        "title": "Message"
                    },
                    "type":
                    {
                        "type": "string",
                        "title": "Error Type"
                    }
                },
                "type": "object",
                "required":
                [
                    "loc",
                    "msg",
                    "type"
                ],
                "title": "ValidationError"
            }
        }
    }
}

@commonism
Copy link
Owner

commonism commented Apr 11, 2025

pydantic 2.11.0 broke it in quite a lot of places, this is only one of them
I'd consider it unusable with pydantic 2.11 atm

Here is the relevant change to pydantic - pydantic/pydantic#11032, it's in the "spacebar heating" stage.

You'll have to nail pydantic to <2.11.0 for now

pydantic.warnings.PydanticDeprecatedSince211: Accessing the 'model_fields' attribute on the instance is deprecated. Instead, you should access this attribute from the model class. Deprecated in Pydantic V2.11 to be removed in V3.0.
@commonism
Copy link
Owner

While I'd prefer pydantic taking responsibility for this regression, let's roll with this for now.

Thanks for notice.

@commonism commonism merged commit a782db2 into commonism:master Apr 12, 2025
8 of 10 checks passed
@commonism
Copy link
Owner

0.8.1 resolves this.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants