Source: fastapi
Version: 0.115.11-4
Severity: serious
Tags: ftbfs
Forwarded: https://github.com/fastapi/fastapi/pull/14036

fastapi FTBFS and fails its autopkgtests with the current version of 
pydantic in unstable (2.12.0~a1-1 - I had no choice but to package an 
alpha release in this case because there was no other combination of 
pydantic/pydantic-core/etc. versions that was usable with the current 
rust-pyo3 transition).

You can see the autopkgtest failure in 
https://ci.debian.net/packages/f/fastapi/testing/amd64/64021591/, and 
here's a version of the failure with "pytest -vv":

  _____________________________ test_openapi_schema 
______________________________

      def test_openapi_schema():
          response = client.get("/openapi.json")
          assert response.status_code == 200, response.text
  >       assert response.json() == {
              "openapi": "3.1.0",
              "info": {"title": "FastAPI", "version": "0.1.0"},
              "paths": {
                  "/items/": {
                      "post": {
                          "responses": {
                              "200": {
                                  "description": "Successful Response",
                                  "content": {"application/json": {"schema": 
{}}},
                              },
                              "422": {
                                  "description": "Validation Error",
                                  "content": {
                                      "application/json": {
                                          "schema": {
                                              "$ref": 
"#/components/schemas/HTTPValidationError"
                                          }
                                      }
                                  },
                              },
                          },
                          "summary": "Save Item No Body",
                          "operationId": "save_item_no_body_items__post",
                          "requestBody": {
                              "content": {
                                  "application/json": {
                                      "schema": {
                                          "title": "Item",
                                          "type": "array",
                                          "items": {"$ref": 
"#/components/schemas/Item"},
                                      }
                                  }
                              },
                              "required": True,
                          },
                      }
                  }
              },
              "components": {
                  "schemas": {
                      "Item": {
                          "title": "Item",
                          "required": ["name", "age"],
                          "type": "object",
                          "properties": {
                              "name": {"title": "Name", "type": "string"},
                              "age": IsDict(
                                  {
                                      "title": "Age",
                                      "anyOf": [
                                          {"exclusiveMinimum": 0.0, "type": 
"number"},
                                          {"type": "string"},
                                      ],
                                  }
                              )
                              | IsDict(
                                  # TODO: remove when deprecating Pydantic v1
                                  {
                                      "title": "Age",
                                      "exclusiveMinimum": 0.0,
                                      "type": "number",
                                  }
                              ),
                          },
                      },
                      "ValidationError": {
                          "title": "ValidationError",
                          "required": ["loc", "msg", "type"],
                          "type": "object",
                          "properties": {
                              "loc": {
                                  "title": "Location",
                                  "type": "array",
                                  "items": {
                                      "anyOf": [{"type": "string"}, {"type": 
"integer"}]
                                  },
                              },
                              "msg": {"title": "Message", "type": "string"},
                              "type": {"title": "Error Type", "type": "string"},
                          },
                      },
                      "HTTPValidationError": {
                          "title": "HTTPValidationError",
                          "type": "object",
                          "properties": {
                              "detail": {
                                  "title": "Detail",
                                  "type": "array",
                                  "items": {"$ref": 
"#/components/schemas/ValidationError"},
                              }
                          },
                      },
                  }
              },
          }
  E       AssertionError: assert {'openapi': '3.1.0', 'info': {'title': 
'FastAPI', 'version': '0.1.0'}, 'paths': {'/items/': {'post': {'summary': 'Save 
Item No Body', 'operationId': 'save_item_no_body_items__post', 'requestBody': 
{'content': {'application/json': {'schema': {'items': {'$ref': 
'#/components/schemas/Item'}, 'type': 'array', 'title': 'Item'}}}, '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': 
{'HTTPValidationError': {'properties': {'detail': {'items': {'$ref': 
'#/components/schemas/ValidationError'}, 'type': 'array', 'title': 'Detail'}}, 
'type': 'object', 'title': 'HTTPValidationError'}, 'Item': {'properties': 
{'name': {'type': 'string', 'title': 'Name'}, 'age': {'anyOf': [{'type': 
'number', 'exclusiveMinimum': 0.0}, {'type': 'string', 'pattern': 
'^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$'}], 'title': 'Age'}}, 'type': 'object', 
'required': ['name', 'age'], 'title': 'Item'}, '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'}}}} == {'openapi': '3.1.0', 'info': {'title': 'FastAPI', 
'version': '0.1.0'}, 'paths': {'/items/': {'post': {'responses': {'200': 
{'description': 'Successful Response', 'content': {'application/json': 
{'schema': {}}}}, '422': {'description': 'Validation Error', 'content': 
{'application/json': {'schema': {'$ref': 
'#/components/schemas/HTTPValidationError'}}}}}, 'summary': 'Save Item No 
Body', 'operationId': 'save_item_no_body_items__post', 'requestBody': 
{'content': {'application/json': {'schema': {'title': 'Item', 'type': 'array', 
'items': {'$ref': '#/components/schemas/Item'}}}}, 'required': True}}}}, 
'components': {'schemas': {'Item': {'title': 'Item', 'required': ['name', 
'age'], 'type': 'object', 'properties': {'name': {'title': 'Name', 'type': 
'string'}, 'age': IsDict(title='Age', anyOf=[{'exclusiveMinimum': 0.0, 'type': 
'number'}, {'type': 'string'}]) | IsDict(title='Age', exclusiveMinimum=0.0, 
type='number')}}, 'ValidationError': {'title': 'ValidationError', 'required': 
['loc', 'msg', 'type'], 'type': 'object', 'properties': {'loc': {'title': 
'Location', 'type': 'array', 'items': {'anyOf': [{'type': 'string'}, {'type': 
'integer'}]}}, 'msg': {'title': 'Message', 'type': 'string'}, 'type': {'title': 
'Error Type', 'type': 'string'}}}, 'HTTPValidationError': {'title': 
'HTTPValidationError', 'type': 'object', 'properties': {'detail': {'title': 
'Detail', 'type': 'array', 'items': {'$ref': 
'#/components/schemas/ValidationError'}}}}}}}
  E
  E         Common items:
  E         {'info': {'title': 'FastAPI', 'version': '0.1.0'},
  E          'openapi': '3.1.0',
  E          'paths': {'/items/': {'post': {'operationId': 
'save_item_no_body_items__post',
  E                                         'requestBody': {'content': 
{'application/json': {'schema': {'items': {'$ref': '#/components/schemas/Item'},
  E                                                                             
                        'title': 'Item',
  E                                                                             
                        'type': 'array'}}},
  E                                                         'required': True},
  E                                         'responses': {'200': {'content': 
{'application/json': {'schema': {}}},
  E                                                               
'description': 'Successful '
  E                                                                             
 'Response'},
  E                                                       '422': {'content': 
{'application/json': {'schema': {'$ref': 
'#/components/schemas/HTTPValidationError'}}},
  E                                                               
'description': 'Validation '
  E                                                                             
 'Error'}},
  E                                         'summary': 'Save Item No Body'}}}}
  E         Differing items:
  E         {'components': {'schemas': {'HTTPValidationError': {'properties': 
{'detail': {'items': {...}, 'title': 'Detail', 'type... 'Error Type', 'type': 
'string'}}, 'required': ['loc', 'msg', 'type'], 'title': 'ValidationError', 
'type': 'object'}}}} != {'components': {'schemas': {'HTTPValidationError': 
{'properties': {'detail': {'items': {...}, 'title': 'Detail', 'type... 'Error 
Type', 'type': 'string'}}, 'required': ['loc', 'msg', 'type'], 'title': 
'ValidationError', 'type': 'object'}}}}
  E
  E         Full diff:
  E           {
  E               'components': {
  E                   'schemas': {
  E                       'HTTPValidationError': {
  E                           'properties': {
  E                               'detail': {
  E                                   'items': {
  E                                       '$ref': 
'#/components/schemas/ValidationError',
  E                                   },
  E                                   'title': 'Detail',
  E                                   'type': 'array',
  E                               },
  E                           },
  E                           'title': 'HTTPValidationError',
  E                           'type': 'object',
  E                       },
  E                       'Item': {
  E                           'properties': {
  E         -                     'age': IsDict(title='Age', 
anyOf=[{'exclusiveMinimum': 0.0, 'type': 'number'}, {'type': 'string'}]) | 
IsDict(title='Age', exclusiveMinimum=0.0, type='number'),
  E         +                     'age': {
  E         +                         'anyOf': [
  E         +                             {
  E         +                                 'exclusiveMinimum': 0.0,
  E         +                                 'type': 'number',
  E         +                             },
  E         +                             {
  E         +                                 'pattern': 
'^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$',
  E         +                                 'type': 'string',
  E         +                             },
  E         +                         ],
  E         +                         'title': 'Age',
  E         +                     },
  E                               'name': {
  E                                   'title': 'Name',
  E                                   'type': 'string',
  E                               },
  E                           },
  E                           'required': [
  E                               'name',
  E                               'age',
  E                           ],
  E                           'title': 'Item',
  E                           'type': 'object',
  E                       },
  E                       'ValidationError': {
  E                           'properties': {
  E                               'loc': {
  E                                   'items': {
  E                                       'anyOf': [
  E                                           {
  E                                               'type': 'string',
  E                                           },
  E                                           {
  E                                               'type': 'integer',
  E                                           },
  E                                       ],
  E                                   },
  E                                   'title': 'Location',
  E                                   'type': 'array',
  E                               },
  E                               'msg': {
  E                                   'title': 'Message',
  E                                   'type': 'string',
  E                               },
  E                               'type': {
  E                                   'title': 'Error Type',
  E                                   'type': 'string',
  E                               },
  E                           },
  E                           'required': [
  E                               'loc',
  E                               'msg',
  E                               'type',
  E                           ],
  E                           'title': 'ValidationError',
  E                           'type': 'object',
  E                       },
  E                   },
  E               },
  E               'info': {
  E                   'title': 'FastAPI',
  E                   'version': '0.1.0',
  E               },
  E               'openapi': '3.1.0',
  E               'paths': {
  E                   '/items/': {
  E                       'post': {
  E                           'operationId': 'save_item_no_body_items__post',
  E                           'requestBody': {
  E                               'content': {
  E                                   'application/json': {
  E                                       'schema': {
  E                                           'items': {
  E                                               '$ref': 
'#/components/schemas/Item',
  E                                           },
  E                                           'title': 'Item',
  E                                           'type': 'array',
  E                                       },
  E                                   },
  E                               },
  E                               'required': True,
  E                           },
  E                           'responses': {
  E                               '200': {
  E                                   'content': {
  E                                       'application/json': {
  E                                           'schema': {},
  E                                       },
  E                                   },
  E                                   'description': 'Successful Response',
  E                               },
  E                               '422': {
  E                                   'content': {
  E                                       'application/json': {
  E                                           'schema': {
  E                                               '$ref': 
'#/components/schemas/HTTPValidationError',
  E                                           },
  E                                       },
  E                                   },
  E                                   'description': 'Validation Error',
  E                               },
  E                           },
  E                           'summary': 'Save Item No Body',
  E                       },
  E                   },
  E               },
  E           }

  tests/test_multi_body_errors.py:136: AssertionError

I pushed an upstream PR to fix this.  Perhaps you could cherry-pick it into 
Debian?

  https://github.com/fastapi/fastapi/pull/14036

At build time there are four more failures in 
tests/test_forms_single_model.py; I'm not sure why they don't show up in 
autopkgtests.  They all seem to be essentially this warning:

  pydantic.warnings.UnsupportedFieldAttributeWarning: The 'alias' attribute 
with value 'with' was provided to the `Field()` function, which has no effect 
in the context it was used. 'alias' is field-specific metadata, and can only be 
attached to a model field using `Annotated` metadata or by assignment. This may 
have happened because an `Annotated` type alias using the `type` statement was 
used, or if the `Field()` function was attached to a single member of a union 
type.

This is due to https://github.com/pydantic/pydantic/pull/12028.  I 
haven't had time to look into it properly yet, although I can if you 
need me to.

Thanks,

-- 
Colin Watson (he/him)                              [[email protected]]

Reply via email to