Skip to content

fix(background_tasks): keep tenant publish validation on custom task bases (#765) - #796

Merged
antosubash merged 6 commits into
mainfrom
feat/b49-bg-tasks-custom-base
Nov 3, 2026
Merged

antosubash merged 6 commits into
mainfrom
feat/b49-bg-tasks-custom-base

Conversation

@antosubash

Copy link
Copy Markdown
Owner

Summary

  • Tenant stamping and validation on apply_async now lives in TenantPublishMixin.
  • TenantCelery._task_from_fun composes that mixin in front of any custom task base (@app.task(base=Custom), shared_task(base=Custom)). Eager runs on a custom base therefore refuse a mismatched tenant header and stamp the caller's tenant and owner, the same as the default TenantTask and broker mode.
  • A custom base's own apply_async still runs once, after validation.
  • A base that cannot be composed (metaclass conflict) raises a TypeError naming it at registration.
  • Only Celery 5.4-compatible arguments are forwarded, so the celery>=5.4 floor still works.
  • TenantTask, TenantPublishMixin and TenantCelery moved to background_tasks/tenant_celery.py, which keeps celery_app.py under the 300-line cap.
  • Docs (docs/modules/background_tasks.md) and CHANGELOG are updated.

Closes #765

Review

/ship pipeline: correctness and maintainability review (Sonnet), triage. Fixed:

  • ty invalid override;
  • Celery 5.4 argument compatibility;
  • the composed class keeps the base's __module__ and __qualname__;
  • an unused __all__ re-export;
  • a shadowed test class name.

Verification

  • make lint: passes.
  • make test-py: 7251 passed. Two local failures were environmental:
    • the /tmp/.git sandbox placeholder;
    • test_eager_publish_from_a_plain_session_is_delivered timed out its 15 s wait while the machine was under load. It passes alone and in a parallel run of the module (625 passed).

https://claude.ai/code/session_01M9neheZZEe3sVpDi2S3zT4

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Deploying simple-module-python with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7713ded
Status: ✅  Deploy successful!
Preview URL: https://89215c08.simple-module-python.pages.dev
Branch Preview URL: https://feat-b49-bg-tasks-custom-bas.simple-module-python.pages.dev

View logs

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-11-03T17:53:37.737227Z 71d28b2 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@antosubash
antosubash merged commit ad27666 into main Nov 3, 2026
17 checks passed
@antosubash
antosubash deleted the feat/b49-bg-tasks-custom-base branch November 3, 2026 18:12
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.

[P2] background_tasks: custom task bases bypass eager tenant validation

1 participant