{"record":{"id":"1930ffe1198f3f72","repo":"hibiken/asynq","slug":"asynq-w","errorCode":null,"errorMessage":"asynq: %w","messagePattern":"asynq: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"inspector.go","lineNumber":247,"sourceCode":"\t\treturn fmt.Errorf(\"%w: queue=%q\", ErrQueueNotFound, queue)\n\t}\n\tif errors.IsQueueNotEmpty(err) {\n\t\treturn fmt.Errorf(\"%w: queue=%q\", ErrQueueNotEmpty, queue)\n\t}\n\treturn err\n}\n\n// GetTaskInfo retrieves task information given a task id and queue name.\n//\n// Returns an error wrapping ErrQueueNotFound if a queue with the given name doesn't exist.\n// Returns an error wrapping ErrTaskNotFound if a task with the given id doesn't exist in the queue.\nfunc (i *Inspector) GetTaskInfo(queue, id string) (*TaskInfo, error) {\n\tinfo, err := i.rdb.GetTaskInfo(queue, id)\n\tswitch {\n\tcase errors.IsQueueNotFound(err):\n\t\treturn nil, fmt.Errorf(\"asynq: %w\", ErrQueueNotFound)\n\tcase errors.IsTaskNotFound(err):\n\t\treturn nil, fmt.Errorf(\"asynq: %w\", ErrTaskNotFound)\n\tcase err != nil:\n\t\treturn nil, fmt.Errorf(\"asynq: %w\", err)\n\t}\n\treturn newTaskInfo(info.Message, info.State, info.NextProcessAt, info.Result), nil\n}\n\n// ListOption specifies behavior of list operation.\ntype ListOption interface{}\n\n// Internal list option representations.\ntype (\n\tpageSizeOpt int\n\tpageNumOpt  int\n)\n\ntype listOption struct {\n\tpageSize int\n\tpageNum  int","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/hibiken/asynq/blob/d135f1439bee74e989b7f9b41ecd542cc87f024a/inspector.go#L229-L265","documentation":"GetTaskInfo returns an error wrapping ErrTaskNotFound when the queue exists but no task with the given id is found in it. The asynq: prefix marks the library as the source. Detect it with errors.Is(err, asynq.ErrTaskNotFound).","triggerScenarios":"Calling Inspector.GetTaskInfo(queue, id) with an id for a task that was already processed and removed, never existed, or exists in a different queue; rdb.GetTaskInfo returns TaskNotFound wrapped at inspector.go:247.","commonSituations":"Looking up a task after it completed and was pruned (retention expired); using a task ID from another queue; caching a stale task ID across restarts.","solutions":["Confirm the task ID matches one returned by Enqueue and that the queue name is correct.","Check task lifecycle: if retention was set, the task is removed after completion; treat ErrTaskNotFound as a normal post-completion outcome.","List tasks (ListPendingTasks etc.) or use Inspector.GetTaskInfo on the correct queue to verify the ID exists."],"exampleFix":"// before\ninfo, err := inspector.GetTaskInfo(\"default\", staleID)\n// after\ninfo, err := inspector.GetTaskInfo(\"default\", taskID)\nif errors.Is(err, asynq.ErrTaskNotFound) {\n    return nil, fmt.Errorf(\"task %s no longer exists (already completed or pruned)\", taskID)\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"info, err := inspector.GetTaskInfo(q, id)\nif errors.Is(err, asynq.ErrTaskNotFound) {\n    // treat as normal: task completed/pruned or wrong id\n}","preventionTips":["Set an appropriate retention when enqueuing if you need post-completion lookups","Never cache task IDs across restarts without revalidation","Match the queue name to the one used at Enqueue time"],"tags":["go","asynq","task","not-found"],"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"}