You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After upgrading to fastapi-cache2 version 0.2.2 or later, endpoints using both fastapi-pagination and the @cache decorator fail with an UninitializedConfigurationError. This appears to be caused by changes in how fastapi-cache2 injects dependencies and wraps route handlers, which prevents fastapi-pagination from properly initializing its own dependencies.
I totally understand that not only your dependency could be the issue, but after my short investigation, I concluded that other dependencies (like fastapi-pagination) could clash with your new dependency injection changes in the v0.2.2 version.
Details:
Versions:
fastapi-cache2 >= 0.2.2 (works in 0.2.0 and 0.2.1)
fastapi-pagination 0.13.1
Error Message:
fastapi_pagination.errors.UninitializedConfigurationError: Use params, add_pagination or pagination_ctx
With fastapi-cache2 0.2.0 or 0.2.1: endpoint works as expected.
With fastapi-cache2 0.2.2 or later: endpoint raises UninitializedConfigurationError.
Troubleshooting Attempts:
Ensured correct decorator order (@router.get above @cache).
Used injected_dependency_namespace in the @cache decorator.
Explicitly injected pagination context with Depends(pagination_ctx).
Confirmed add_pagination(app) is called after all routers.
None of these resolved the issue with v0.2.2+.
Analysis:
The problem appears to be caused by changes in dependency injection and route wrapping introduced in fastapi-cache2 v0.2.2.
The new dependency injection mechanism in the cache decorator seems to prevent other dependencies (like those from fastapi-pagination) from being properly initialized.
This is not a problem with fastapi-pagination itself, but with how fastapi-cache2 wraps the route and handles dependencies.
Environment:
fastapi-cache2: 0.2.2 (and later)
fastapi-pagination: 0.13.1
FastAPI: 0.115.12
Workaround:
Downgrading to fastapi-cache2 0.2.0 or 0.2.1 resolves the issue.
Request:
Please investigate the changes in dependency injection and route wrapping introduced in v0.2.2.
Ideally, fastapi-cache2 should be compatible with other libraries that use FastAPI's dependency injection system, such as fastapi-pagination.
Thank you for your work on this project! Please let me know if you need more details or a full reproduction repo.
Let me know if you want to add or remove any details!
Activity