Skip to content

Commit e149e68

Browse files
snopokeclaude
andcommitted
fix AttributeError when result.info is not a dict
result.info returns the task's return value (e.g. an int) when the Celery task completes before apply_async checks it. Use isinstance check instead of truthiness to avoid calling .get() on non-dict values. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent d772d01 commit e149e68

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

taskbadger/celery.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ def apply_async(self, *args, **kwargs):
131131

132132
result = super().apply_async(*args, **kwargs)
133133

134-
tb_task_id = result.info.get(TB_TASK_ID) if result.info else None
134+
tb_task_id = result.info.get(TB_TASK_ID) if isinstance(result.info, dict) else None
135135
setattr(result, TB_TASK_ID, tb_task_id)
136136

137137
_get_task = functools.partial(get_task, tb_task_id) if tb_task_id else lambda: None

0 commit comments

Comments
 (0)