fix: update Job status to FAILED when job_pipeline raises an exception - #3972
fix: update Job status to FAILED when job_pipeline raises an exception#3972Aditya30ag wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes a Celery job lifecycle bug where exceptions raised during Job.execute() inside job_pipeline could leave the Job row stuck in RUNNING, preventing UI updates, cleanup, and investigation status propagation.
Changes:
- Mark the
JobasFAILEDand setfinished_analysis_timewhenjob.execute()raises. - Persist the exception message into
job.errors. - Send a WebSocket update and propagate status recalculation to the root
Investigation.
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| @@ -262,6 +267,12 @@ def job_pipeline( | |||
| ): | |||
| report.status = report.STATUSES.FAILED.value | |||
| report.save() | |||
| JobConsumer.serialize_and_send_job(job) | |||
|
Hey @berardifra, |
b6bcfd4 to
fbb27a0
Compare
fbb27a0 to
c6fed10
Compare
c6fed10 to
baf4d46
Compare
Closes intelowlproject#3653 Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
baf4d46 to
93bd6b8
Compare
|
Hi @Aditya30ag, thanks for tagging me. I opened #3976 with a small branch against I also referenced your PR in the description so the context is preserved. |
|
@berardifra |
Description
When
job.execute()raises insidejob_pipeline, theexceptblock only marked individual plugin reports as failed it never updated theJobrow itself.Since
execute()setsjob.status = RUNNINGas its first action, and the Celery chain (includingjob_set_final_status) never dispatches on exception, the job gets permanently stuck inRUNNING.Consequences:
remove_old_jobsnever cleans the jobfinished_analysis_timestaysNULLInvestigationstatus is never updatedFix: In the
exceptblock, immediately setjob.status = FAILED,job.finished_analysis_time = now(), append the error, persist withjob.save(update_fields=[...]), push a WebSocket notification, and propagate failure to the parentInvestigationif one exists.This matches the pattern already used in
run_plugin(line 295 oftasks.py).Type of change
Issue #3653
Checklist
developRuff) gave 0 errorstests/folder). All tests gave 0 errors