GopeedLab/gopeed · error

task not found

Error message

task not found

What it means

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).

Source

Thrown at pkg/download/downloader.go:46

)

const (
	// task info bucket
	bucketTask = "task"
	// task download data bucket
	bucketSave = "save"
	// protocol-level shared client state bucket
	bucketProtocolState = "protocol_state"
	// downloader config bucket
	bucketConfig = "config"
	// downloader extension bucket
	bucketExtension = "extension"
	// downloader extension storage bucket
	bucketExtensionStorage = "extension_storage"
)

var (
	ErrTaskNotFound        = errors.New("task not found")
	ErrUnSupportedProtocol = errors.New("unsupported protocol")
)

type Listener func(event *Event)

// ExtractStatus represents the current status of archive extraction
type ExtractStatus string

const (
	// ExtractStatusNone indicates extraction has not started
	ExtractStatusNone ExtractStatus = ""
	// ExtractStatusQueued indicates extraction is waiting in the queue
	ExtractStatusQueued ExtractStatus = "queued"
	// ExtractStatusWaitingParts indicates waiting for other multi-part archive parts to complete
	ExtractStatusWaitingParts ExtractStatus = "waitingParts"
	// ExtractStatusExtracting indicates extraction is in progress
	ExtractStatusExtracting ExtractStatus = "extracting"
	// ExtractStatusDone indicates extraction completed successfully

View on GitHub (pinned to 7b7327ffb3)

Solutions

  1. Verify with downloader.GetTask(id) != nil before Patch, and handle nil id gracefully
  2. For Pause, treat ErrTaskNotFound as idempotent success if the goal is 'make sure it is paused'
  3. Re-check task lists (GetTasksByFilter) instead of caching task ids long-term
  4. Make sure you use the taskId returned by Create, not the Resolve rrId

Example fix

// before
err := d.Pause(&download.TaskFilter{IDs: []string{id}})
if err != nil { return err } // second pause errors

// after
err := d.Pause(&download.TaskFilter{IDs: []string{id}})
if errors.Is(err, download.ErrTaskNotFound) { return nil } // already paused/removed
if err != nil { return err }
Defensive patterns

Strategy: try-catch

Validate before calling

if downloader.GetTask(taskId) == nil {
    // task does not exist (yet): skip or re-fetch the task list
    return nil
}
err := downloader.Patch(taskId, req, opts)

Try / catch

err := downloader.Patch(taskId, req, opts)
if errors.Is(err, download.ErrTaskNotFound) {
    // stale id: refresh task list; do not blindly retry with the same id
}
err = downloader.Pause(filter)
if errors.Is(err, download.ErrTaskNotFound) { err = nil } // idempotent pause

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of GopeedLab/gopeed@7b7327ffb3 (2026-08-16). Data as JSON: /api/errors/96b7dcf8fd0d87d5. Report an issue: GitHub.