diff --git a/src/jobservice_v2/pool/redis_pool.go b/src/jobservice_v2/pool/redis_pool.go index 0de8e69ee..98143ba89 100644 --- a/src/jobservice_v2/pool/redis_pool.go +++ b/src/jobservice_v2/pool/redis_pool.go @@ -256,6 +256,11 @@ func (gcwp *GoCraftWorkPool) Enqueue(jobName string, params models.Parameters, i return models.JobStats{}, err } + //avoid backend pool bug + if j == nil { + return models.JobStats{}, fmt.Errorf("job '%s' can not be enqueued, please check the job metatdata", jobName) + } + res := generateResult(j, job.JobKindGeneric, isUnique) //Save data with async way. Once it fails to do, let it escape //The client method may help if the job is still in progress when get stats of this job @@ -282,6 +287,11 @@ func (gcwp *GoCraftWorkPool) Schedule(jobName string, params models.Parameters, return models.JobStats{}, err } + //avoid backend pool bug + if j == nil { + return models.JobStats{}, fmt.Errorf("job '%s' can not be enqueued, please check the job metatdata", jobName) + } + res := generateResult(j.Job, job.JobKindScheduled, isUnique) res.Stats.RunAt = j.RunAt