{"record":{"id":"96b7dcf8fd0d87d5","repo":"GopeedLab/gopeed","slug":"task-not-found","errorCode":null,"errorMessage":"task not found","messagePattern":"task not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/download/downloader.go","lineNumber":46,"sourceCode":")\n\nconst (\n\t// task info bucket\n\tbucketTask = \"task\"\n\t// task download data bucket\n\tbucketSave = \"save\"\n\t// protocol-level shared client state bucket\n\tbucketProtocolState = \"protocol_state\"\n\t// downloader config bucket\n\tbucketConfig = \"config\"\n\t// downloader extension bucket\n\tbucketExtension = \"extension\"\n\t// downloader extension storage bucket\n\tbucketExtensionStorage = \"extension_storage\"\n)\n\nvar (\n\tErrTaskNotFound        = errors.New(\"task not found\")\n\tErrUnSupportedProtocol = errors.New(\"unsupported protocol\")\n)\n\ntype Listener func(event *Event)\n\n// ExtractStatus represents the current status of archive extraction\ntype ExtractStatus string\n\nconst (\n\t// ExtractStatusNone indicates extraction has not started\n\tExtractStatusNone ExtractStatus = \"\"\n\t// ExtractStatusQueued indicates extraction is waiting in the queue\n\tExtractStatusQueued ExtractStatus = \"queued\"\n\t// ExtractStatusWaitingParts indicates waiting for other multi-part archive parts to complete\n\tExtractStatusWaitingParts ExtractStatus = \"waitingParts\"\n\t// ExtractStatusExtracting indicates extraction is in progress\n\tExtractStatusExtracting ExtractStatus = \"extracting\"\n\t// ExtractStatusDone indicates extraction completed successfully","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/GopeedLab/gopeed/blob/7b7327ffb30816273a74b142cccc0bc10c5a4c67/pkg/download/downloader.go#L28-L64","documentation":"pkg/download sentinel ErrTaskNotFound (downloader.go:46) is returned when an operation targets no existing task: Patch returns it when GetTask(id) is nil (downloader.go:545-548), Pause returns it when the filter matches no pausable tasks (downloader.go:593-597 — the filter forcibly excludes pause/error/done statuses).","triggerScenarios":"Downloader.Patch with a wrong, typo'd, or already-deleted task id; Patch on a task from a previous Downloader instance/storage that was never restored; Pause with a filter (e.g. by status running) that matches zero tasks because all matching ones are already paused/errored/done; racing Delete vs Patch.","commonSituations":"Stale task id held by a UI after the task was removed; calling Pause(id) twice — the second call finds nothing (status is already pause) and returns ErrTaskNotFound; cross-instance task ids; id mix-ups between resourceId (rrId) and taskId.","solutions":["Verify with downloader.GetTask(id) != nil before Patch, and handle nil id gracefully","For Pause, treat ErrTaskNotFound as idempotent success if the goal is 'make sure it is paused'","Re-check task lists (GetTasksByFilter) instead of caching task ids long-term","Make sure you use the taskId returned by Create, not the Resolve rrId"],"exampleFix":"// before\nerr := d.Pause(&download.TaskFilter{IDs: []string{id}})\nif err != nil { return err } // second pause errors\n\n// after\nerr := d.Pause(&download.TaskFilter{IDs: []string{id}})\nif errors.Is(err, download.ErrTaskNotFound) { return nil } // already paused/removed\nif err != nil { return err }","handlingStrategy":"try-catch","validationCode":"if downloader.GetTask(taskId) == nil {\n    // task does not exist (yet): skip or re-fetch the task list\n    return nil\n}\nerr := downloader.Patch(taskId, req, opts)","typeGuard":null,"tryCatchPattern":"err := downloader.Patch(taskId, req, opts)\nif errors.Is(err, download.ErrTaskNotFound) {\n    // stale id: refresh task list; do not blindly retry with the same id\n}\nerr = downloader.Pause(filter)\nif errors.Is(err, download.ErrTaskNotFound) { err = nil } // idempotent pause","preventionTips":["Treat ErrTaskNotFound from Pause as success when the goal is a final state","Don't cache task ids long-term; re-query GetTasksByFilter","Use the taskId from Create, never the Resolve rrId"],"tags":["task","not-found","api"],"backgroundTag":null,"analyzedSha":"7b7327ffb30816273a74b142cccc0bc10c5a4c67","analyzedAt":"2026-08-16T02:51:03.250Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}