Skip to content

✨ Quality: Celery task result endpoint crashes on task failure - #5966

Closed
tang-vu wants to merge 1 commit into
pallets:mainfrom
tang-vu:contribai/improve/quality/celery-task-result-endpoint-crashes-on-t
Closed

tang-vu wants to merge 1 commit into
pallets:mainfrom
tang-vu:contribai/improve/quality/celery-task-result-endpoint-crashes-on-t

Conversation

@tang-vu

@tang-vu tang-vu commented Mar 27, 2026

Copy link
Copy Markdown

✨ Code Quality

Problem

When a Celery task fails, result.ready() evaluates to True but result.successful() is False.
Calling result.get() without propagate=False on a failed task will re-raise the task's exception, causing the Flask endpoint to crash with a 500 Internal Server Error instead of returning the task's failed status.
Additionally, if result.result is an Exception object, returning it directly in the dictionary will cause a TypeError during JSON serialization.

Severity: medium
File: examples/celery/src/task_app/views.py

Solution

When a Celery task fails, result.ready() evaluates to True but result.successful() is False.
Calling result.get() without propagate=False on a failed task will re-raise the task's exception, causing the Flask endpoint to crash with a 500 Internal Server Error instead of returning the task's failed status.
Additionally, if result.result is an Exception object, returning it directly in the dictionary will cause a TypeError during JSON serialization.

Changes

  • examples/celery/src/task_app/views.py (modified)

🤖 About this PR

This pull request was generated by ContribAI, an AI agent
that helps improve open source projects. The change was:

  1. Discovered by automated code analysis
  2. Generated by AI with context-aware code generation
  3. Self-reviewed by AI quality checks

If you have questions or feedback about this PR, please comment below.
We appreciate your time reviewing this contribution!

Closes #5965

When a Celery task fails, `result.ready()` evaluates to `True` but `result.successful()` is `False`. 
Calling `result.get()` without `propagate=False` on a failed task will re-raise the task's exception, causing the Flask endpoint to crash with a 500 Internal Server Error instead of returning the task's failed status. 
Additionally, if `result.result` is an Exception object, returning it directly in the dictionary will cause a `TypeError` during JSON serialization.


Affected files: views.py

Signed-off-by: Tang Vu <vuminhtang2212@gmail.com>
@ThiefMaster

Copy link
Copy Markdown
Member

Do not have AI tools open issues or create PRs. Thanks.

@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Apr 11, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: celery task result endpoint crashes on task failure

2 participants