Skip to content

feat: let middlewares declare task-only labels - #725

Open
summer000 wants to merge 1 commit into
taskiq-python:masterfrom
summer000:feature/task-local-labels
Open

summer000 wants to merge 1 commit into
taskiq-python:masterfrom
summer000:feature/task-local-labels

Conversation

@summer000

Copy link
Copy Markdown

Some middlewares need a task-level parameter that isn't serialized and is read from the registered task instead of from the message, the way types_of_exceptions works for the retry middlewares.

Currently this only works for types_of_exceptions, because the kicker skips it by name when building a message. This means core code knows about parameters used by a specific middleware, and custom middlewares have no way to get the same behavior for their own labels.

This PR lets a middleware declare such labels itself via task_only_labels. The kicker skips them when building a message, and the retry middlewares declare types_of_exceptions this way instead of the hardcoded check.

The kicker hardcoded the `types_of_exceptions` label name to keep it
off the wire. That leaks middleware-specific knowledge into core code.

Add a `task_only_labels` declaration to TaskiqMiddleware. Labels named
there should be read only from the registered task and are skipped when
kicker builds a message, so they are not serialized.
@codecov

codecov Bot commented Nov 17, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.55%. Comparing base (9214379) to head (62f5fde).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #725      +/-   ##
==========================================
+ Coverage   85.49%   85.55%   +0.05%     
==========================================
  Files          68       68              
  Lines        2662     2672      +10     
==========================================
+ Hits         2276     2286      +10     
  Misses        386      386              

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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