-
-
Notifications
You must be signed in to change notification settings - Fork 96
fix: TaskiqAdminMiddleware doesn't work with dataclasses #554
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0cf4e30 to
f3f57d7
Compare
f3f57d7 to
8a21f11
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a bug where TaskiqAdminMiddleware was failing when task arguments contained dataclasses or other non-pydantic types. The fix converts TaskiqMessage and TaskiqResult objects to dictionaries using model_dump() before extracting fields for JSON serialization, ensuring proper serialization of nested objects.
Key changes:
- Modified
TaskiqAdminMiddlewareto usemodel_dump()on message and result objects before accessing their fields - Updated
taskiq/compat.pyto modernize type hints and fix a condition ordering issue - Replaced the old admin middleware test file with a new comprehensive test suite that verifies serialization of dataclasses, TypedDicts, and Pydantic models
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| taskiq/middlewares/taskiq_admin_middleware.py | Fixed serialization by converting messages/results to dicts before field access |
| taskiq/compat.py | Modernized type hints and fixed version comparison condition |
| tests/middlewares/test_taskiq_admin_middleware.py | Removed old test file |
| tests/middlewares/admin_middleware/test_arguments_formatting.py | Added new parameterized tests for different DTO types |
| tests/middlewares/admin_middleware/dto.py | Added test DTOs (dataclass, TypedDict, Pydantic) |
| tests/middlewares/admin_middleware/conftest.py | Added test fixtures for mock admin server and broker setup |
| pyproject.toml | Added polyfactory dependency for test data generation |
| uv.lock | Updated lock file with new dependencies |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
8a21f11 to
253624d
Compare
ae3180a to
9e0c8e8
Compare
9e0c8e8 to
8c053fe
Compare
No description provided.