Skip to content

fix(api): register logger and webhook background tasks in CELERY_IMPORTS (Solves Issue #9357)#9360

Open
geeked-anshuk666 wants to merge 1 commit into
makeplane:previewfrom
geeked-anshuk666:fix/celery-unregistered-tasks
Open

fix(api): register logger and webhook background tasks in CELERY_IMPORTS (Solves Issue #9357)#9360
geeked-anshuk666 wants to merge 1 commit into
makeplane:previewfrom
geeked-anshuk666:fix/celery-unregistered-tasks

Conversation

@geeked-anshuk666

@geeked-anshuk666 geeked-anshuk666 commented Jul 5, 2026

Copy link
Copy Markdown

Description

Fixes a production and self-hosted issue where the Celery worker rejects and discards all API activity log tasks (plane.bgtasks.logger_task.process_logs) enqueued by APITokenLogMiddleware, returning Received unregistered task / KeyError.

Root cause: The plane.bgtasks.logger_task and plane.bgtasks.webhook_task modules were not loaded by Celery at startup, preventing their tasks from being registered on the Celery application.

Fix:

  1. Added both background task modules explicitly to the CELERY_IMPORTS tuple in apps/api/plane/settings/common.py.
  2. Created a new unit test in apps/api/plane/tests/unit/settings/test_celery_imports.py to check that both modules are declared in settings and successfully registered in the Celery registry.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Screenshots and Media (if applicable)

N/A (Backend task registration fix)

Test Scenarios

  1. Verify settings: Run unit tests to check that task files are imported by default loader and registered on the Celery application.
  2. In production/worker logs, verify that enqueuing process_logs tasks does not result in unregistered task errors.

References

Fixes #9357

Summary by CodeRabbit

  • Bug Fixes
    • Improved background task loading so event logging and webhook processing are available more reliably.
    • Added test coverage to verify the expected background tasks are registered and ready to run.

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 824cd0ea-02b9-4e27-9483-e48cd515800a

📥 Commits

Reviewing files that changed from the base of the PR and between 7fbf14a and 55e9f93.

📒 Files selected for processing (2)
  • apps/api/plane/settings/common.py
  • apps/api/plane/tests/unit/settings/test_celery_imports.py

📝 Walkthrough

Walkthrough

Two Celery task modules, plane.bgtasks.logger_task and plane.bgtasks.webhook_task, were added to CELERY_IMPORTS in the settings module. A new unit test file was added to verify these modules are listed and that corresponding tasks register in Celery's current_app.tasks.

Changes

Celery task import fix

Layer / File(s) Summary
Register missing task modules
apps/api/plane/settings/common.py
Adds plane.bgtasks.logger_task and plane.bgtasks.webhook_task to CELERY_IMPORTS under a new "background tasks" comment.
Validation test
apps/api/plane/tests/unit/settings/test_celery_imports.py
New test module asserting CELERY_IMPORTS contains the expected module paths and that the tasks register in current_app.tasks after import_default_modules().

Estimated code review effort: 1 (Trivial) | ~3 minutes

Related issues: #9357 — fixes celery worker discarding API-request log tasks due to missing plane.bgtasks.logger_task entry in CELERY_IMPORTS.

Suggested labels: bug, celery, backend

Suggested reviewers: none identified from provided context

Poem:
A rabbit hopped through settings deep,
Found tasks the worker couldn't keep,
Logger and webhook, lost in the queue,
Now listed plainly, registered true,
Tests confirm what config now shows —
No more discarded logs to bemoan.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: registering logger and webhook background tasks in CELERY_IMPORTS.
Description check ✅ Passed The PR description follows the template and covers the change, type, screenshots, tests, and references.
Linked Issues check ✅ Passed The changes satisfy #9357 by adding both task modules to CELERY_IMPORTS and adding verification tests.
Out of Scope Changes check ✅ Passed The diff is limited to the Celery import setting and a targeted unit test, with no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

[bug]: celery worker discards every API-request log task — plane.bgtasks.logger_task missing from CELERY_IMPORTS

1 participant