Skip to content

Guard against unregistered task in before_task_publish handler - #57

Merged
snopoke merged 1 commit into
mainfrom
sk/ctask-none
Jul 27, 2026
Merged

Guard against unregistered task in before_task_publish handler#57
snopoke merged 1 commit into
mainfrom
sk/ctask-none

Conversation

@snopoke

@snopoke snopoke commented Jul 27, 2026

Copy link
Copy Markdown
Collaborator

before_task_publish fires wherever .delay()/.apply_async() is called, which can be a producer process that hasn't imported the task module. In that case celery.current_app.tasks.get(sender) returns None, and the unconditional ctask.update_state(...) call crashed with AttributeError: 'NoneType' object has no attribute 'update_state'.

TaskBadger task creation still happens via create_task_safe; only the local Celery state update is skipped when the task class isn't registered.

celery.current_app.tasks.get(sender) can return None when the
publishing process hasn't imported the task, crashing update_state().

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@snopoke
snopoke marked this pull request as ready for review July 27, 2026 13:38
@snopoke
snopoke merged commit 92d191a into main Jul 27, 2026
7 of 12 checks passed
@snopoke
snopoke deleted the sk/ctask-none branch July 27, 2026 13:47
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.

1 participant