Skip to content

Support custom task ID generation across dispatch and canvas - #11128

Open
qfarizon-qftech wants to merge 14 commits into
celery:mainfrom
qfarizon-qftech:feature/custom-task-id-generator
Open

qfarizon-qftech wants to merge 14 commits into
celery:mainfrom
qfarizon-qftech:feature/custom-task-id-generator

Conversation

@qfarizon-qftech

Copy link
Copy Markdown

Add task_id_generator, a zero-argument callable whose result is converted to a string for new task and canvas IDs. This supports UUIDv7, ULIDs and application-specific IDs while retaining supplied IDs and native retry identity. With no custom generator, or if it raises, Celery uses Kombu's default UUID generator.

This continues @jiisanda's work in #9713, rebased onto current main, as requested in #9713 (comment). The original commits and their authorship are retained. Prepared with AI assistance and reviewed against the current dispatch, canvas and backend paths.

The follow-up completes eager execution (Task.apply and task_always_eager), uses the configured generator for missing chord-error callback IDs, resolves generators consistently across configuration styles, and preserves the current behavior for empty IDs, nested groups and app-bound signatures. The configuration documentation includes ULID and Python 3.14 UUIDv7 examples.

Tests cover normal and eager execution; signatures, groups, chains, chords, map, starmap, chunks and a composed workflow; repeated freezing; explicit IDs; published retry IDs; missing/failed generators; app selection; and chord-error handling. A real worker/Redis check verifies completed results for one-off, chain, group, chord and retry workflows using UUIDv7, plus preservation of an explicit ID.

The default remains a call to Kombu's UUID generator, with no UUID version hardcoded and no dependency on celery/kombu#2303. That related change can determine the default independently.

Fixes #9662. Continues #9713.

Validation

  • Full unit suite on Python 3.14.3: 5,593 passed, 17 skipped, 2 expected failures; 27,675 subtests passed.
  • All pre-commit hooks pass on the changed files, including flake8, isort and mypy.
  • Real Redis broker/result backend and worker: one-off, chain, group, chord and retry results pass; explicit IDs and retry IDs are preserved.
  • Sphinx configcheck reports the same 28 pre-existing undocumented settings on this branch and main; task_id_generator is recognized and introduces no additional missing-setting errors.

jiisanda and others added 12 commits November 18, 2026 09:36
Honor the configured generator during eager execution, preserve IDs across retries and resolve the owning app for canvas IDs. Retain main behavior for empty IDs, parent groups and serialized signatures, and use the generator when chord error handling creates a missing callback ID.

Register configuration aliases, document the Kombu default and UUIDv7 usage, and cover all canvas primitives, native retry publications and generator fallback. Full unit suite: 5593 passed, 17 skipped, 2 xfailed, 27675 subtests; pre-commit hooks and real Redis worker workflows passed.
@auvipy
auvipy self-requested a review November 18, 2026 08:58
@auvipy auvipy modified the milestones: 5.7.x, 5.8.0 Nov 18, 2026
Comment thread docs/userguide/configuration.rst Resolved
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (715b8a6) to head (e4893f7).

Additional details and impacted files
@@             Coverage Diff             @@
##             main   #11128       +/-   ##
===========================================
- Coverage   91.21%        0   -91.22%     
===========================================
  Files         153        0      -153     
  Lines       21778        0    -21778     
  Branches     2701        0     -2701     
===========================================
- Hits        19865        0    -19865     
+ Misses       1612        0     -1612     
+ Partials      301        0      -301     
Flag Coverage Δ
unittests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@auvipy

auvipy commented Nov 18, 2026

Copy link
Copy Markdown
Member

after merging celery/kombu#2303 we will consider this

.. code-block:: python

# Using ULID (pip install python-ulid)
import ulid

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be we should also consider ulid support in kombu as well

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.

Support custom task ID generator

4 participants