fastapi-pagination: Pydantic v2 migration problem
Hi! I’m using FastApi 0.101.1 and Pydantic 1.10.7 and it works great, but I’m trying to migrate to Pydantic 2.1.1 and I’m getting this error.
INFO: Started server process [7591]
INFO: Waiting for application startup.
ERROR: Traceback (most recent call last):
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/starlette/routing.py", line 677, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/starlette/routing.py", line 566, in __aenter__
await self._router.startup()
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/starlette/routing.py", line 656, in startup
handler()
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi_pagination/api.py", line 339, in on_startup
_add_pagination(parent)
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi_pagination/api.py", line 331, in _add_pagination
_update_route(route)
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi_pagination/api.py", line 317, in _update_route
get_parameterless_sub_dependant(
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 124, in get_parameterless_sub_dependant
return get_sub_dependant(depends=depends, dependency=depends.dependency, path=path)
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 147, in get_sub_dependant
sub_dependant = get_dependant(
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 268, in get_dependant
sub_dependant = get_param_sub_dependant(
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 111, in get_param_sub_dependant
return get_sub_dependant(
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 147, in get_sub_dependant
sub_dependant = get_dependant(
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 289, in get_dependant
add_param_to_fields(field=param_field, dependant=dependant)
File "/Users/pjcopado/.pyenv/versions/project/lib/python3.10/site-packages/fastapi/dependencies/utils.py", line 462, in add_param_to_fields
if field_info.in_ == params.ParamTypes.path:
AttributeError: 'FieldInfo' object has no attribute 'in_'
ERROR: Application startup failed. Exiting.
If I comment the line add_pagination(app) in main.py, the application works, but of course the paginated endpoints won’t.
Is there any change I have to make?
Thanks!
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Comments: 15 (8 by maintainers)
I guess this is actually
fastapiissue, notfastapi-paginationitself.I will close this issue but will keep in mind that this can happen. I will add documentation for this case.
Ok so I literally deleted my whole main.py file and it’s only the same code as yours, and still getting the problem.
I think there might be another library messing up…
Btw, I’m using Python 3.10.6
Thanks, I will take a look!
I just found out the issue appears when I create a custom Page