{"record":{"id":"c04e1af4e9ac820f","repo":"hibiken/asynq","slug":"task-not-found","errorCode":null,"errorMessage":"task not found","messagePattern":"task not found","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"inspector.go","lineNumber":213,"sourceCode":"\t\tres = append(res, &DailyStats{\n\t\t\tQueue:     s.Queue,\n\t\t\tProcessed: s.Processed,\n\t\t\tFailed:    s.Failed,\n\t\t\tDate:      s.Time,\n\t\t})\n\t}\n\treturn res, nil\n}\n\nvar (\n\t// ErrQueueNotFound indicates that the specified queue does not exist.\n\tErrQueueNotFound = errors.New(\"queue not found\")\n\n\t// ErrQueueNotEmpty indicates that the specified queue is not empty.\n\tErrQueueNotEmpty = errors.New(\"queue is not empty\")\n\n\t// ErrTaskNotFound indicates that the specified task cannot be found in the queue.\n\tErrTaskNotFound = errors.New(\"task not found\")\n)\n\n// DeleteQueue removes the specified queue.\n//\n// If force is set to true, DeleteQueue will remove the queue regardless of\n// the queue size as long as no tasks are active in the queue.\n// If force is set to false, DeleteQueue will remove the queue only if\n// the queue is empty.\n//\n// If the specified queue does not exist, DeleteQueue returns ErrQueueNotFound.\n// If force is set to false and the specified queue is not empty, DeleteQueue\n// returns ErrQueueNotEmpty.\nfunc (i *Inspector) DeleteQueue(queue string, force bool) error {\n\terr := i.rdb.RemoveQueue(queue, force)\n\tif errors.IsQueueNotFound(err) {\n\t\treturn fmt.Errorf(\"%w: queue=%q\", ErrQueueNotFound, queue)\n\t}\n\tif errors.IsQueueNotEmpty(err) {","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/inspector.go#L195-L231","documentation":"ErrTaskNotFound indicates the specified task cannot be found in the queue. Inspector task operations (GetTaskInfo, DeleteTask, RunTask, ArchiveTask, UpdateTaskPayload) map the internal not-found error to this sentinel when the task ID doesn't match any task in the given queue/state.","triggerScenarios":"inspector.GetTaskInfo(q, id) for an ID that never existed; the task already completed and passed its retention window; the task moved between states/queues; calling from a different Redis DB than the one that holds the task.","commonSituations":"Acting on a task ID stored before the task expired; race where the task finishes between lookup and action; retention not configured so completed tasks vanish immediately; inspecting the wrong queue name.","solutions":["Verify the task ID and queue name; list tasks (e.g. ListPendingTasks) to confirm it exists.","Set asynq.Retention on enqueue so completed tasks remain inspectable for a while.","Handle errors.Is(err, asynq.ErrTaskNotFound) as expected when tasks may have already completed.","Point the Inspector at the same Redis instance that served the task."],"exampleFix":"// before\ninfo, err := insp.GetTaskInfo(\"default\", id)\nif err != nil { return err }\n// after\ninfo, err := insp.GetTaskInfo(\"default\", id)\nif errors.Is(err, asynq.ErrTaskNotFound) {\n    return nil // task already done\n} else if err != nil {\n    return err\n}","handlingStrategy":"type-guard","validationCode":"// Check task still exists before acting:\nif _, err := insp.GetTaskInfo(q, id); errors.Is(err, asynq.ErrTaskNotFound) { return ErrTaskGone }","typeGuard":"func isTaskNotFound(err error) bool { return errors.Is(err, asynq.ErrTaskNotFound) }","tryCatchPattern":"if err := insp.DeleteTask(q, id); err != nil {\n    if isTaskNotFound(err) { return nil }\n    return err\n}","preventionTips":["Set Retention on tasks you intend to inspect after completion","Act on task IDs promptly; tasks expire or move states","Store queue name alongside the task ID and use it consistently"],"tags":["redis","task","not-found","inspector"],"backgroundTag":"record-not-found","analyzedSha":"d135f1439bee74e989b7f9b41ecd542cc87f024a","analyzedAt":"2026-09-07T19:02:34.660Z","contentChangedAt":"2026-09-07T19:02:34.660Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}