AlistGo/alist · warning · ErrTaskNotFound

task not found

Error message

task not found

What it means

ErrTaskNotFound from the task manager (pkg/task/manager.go): Retry, Cancel, or Remove was called with a task ID that is not present in the manager's in-memory task map (returned wrapped with errors.WithStack).

Source

Thrown at pkg/task/errors.go:6

package task

import "errors"

var (
	ErrTaskNotFound = errors.New("task not found")
	ErrTaskRunning  = errors.New("task is running")
)

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Check existence first with Manager.Get(tid) and refresh the task list before acting
  2. After an alist restart, resubmit work instead of retrying old task IDs — tasks do not survive restarts
  3. Make sure you call the correct manager instance for the task kind

Example fix

// before
err := taskManager.Retry(id)

// after
if _, ok := taskManager.Get(id); !ok {
    // refresh task list; task gone (restart or cleared)
    tasks = taskManager.GetAll()
    return nil
}
err := taskManager.Retry(id)
Defensive patterns

Strategy: validation

Validate before calling

if _, ok := taskManager.Get(tid); !ok {
	return errors.New("task not present; refresh the task list")
}

Try / catch

err := taskManager.Cancel(tid)
if errors.Is(err, task.ErrTaskNotFound) {
	// treat as already-finished; refresh UI state
	return nil
}

Prevention

When it happens

Trigger: Calling Manager.Retry(tid)/Cancel(tid)/Remove(tid) for a task that was never submitted, was already removed, or belongs to a different Manager instance (tasks are not persisted).

Common situations: UI holds a stale task list after an alist restart (task registry is memory-only and empty), calling retry/cancel after ClearDone removed the task, or using an ID from a different task type's manager (copy vs. upload managers are separate).

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/6667c22f6be7991d. Report an issue: GitHub.