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:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user