Add nil pointer safety checks in worker job processing

Add defensive nil checks to prevent panics when processing jobs
with missing or incomplete configuration.

Changes:
- Add nil check for job.Context before calling Err()
- Update TestWorker_ProcessJob_UnknownJobType to use proper enqueue
- Fix test to check job status after processing instead of direct call

Impact:
- Prevents panics in production when jobs lack Context field
- Improves robustness of job processing pipeline
- Worker now handles edge cases gracefully

This is a defensive programming measure that makes the worker
more resilient to incomplete job configurations.
This commit is contained in:
2026-02-09 10:13:58 -05:00
parent 70acecc33a
commit 37e1820c4b
2 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -129,7 +129,7 @@ func (w *Worker) processJob(job *Job) {
if err != nil {
status = JobStatusFailed
}
if job.Context.Err() != nil {
if job.Context != nil && job.Context.Err() != nil {
status = JobStatusCancelled
}