agalwood/Motrix · warning · AppError

TaskNotFound

TaskNotFound

Error message

Task not found: ${taskId}

What it means

Thrown by the Task Inspector Activity query after the taskId is validated and the underlying reader.snapshot(taskId) is called: if the reader returns null/undefined, no activity snapshot exists for that task and TaskNotFound is raised. The taskId is included in the message.

Source

Thrown at src/core/inspector-activity/task-inspector-activity-query.ts:63

        return invalid()
      }
      const descriptor = Object.getOwnPropertyDescriptor(params, 'taskId')
      if (!descriptor || !('value' in descriptor)) {
        return invalid()
      }
      let taskId: string
      try {
        taskId = assertTaskId(descriptor.value as string)
      } catch {
        return invalid()
      }
      queryCount += 1
      if (options.failAfterFirstQuery && queryCount > 1) {
        throw new Error('deterministic Task Inspector Activity query failure')
      }
      const result = reader.snapshot(taskId)
      if (result == null) {
        throw new AppError(ErrorCode.TaskNotFound, `Task not found: ${taskId}`)
      }
      const snapshot = parseTaskInspectorActivitySnapshot(result, taskId)
      if (!snapshot) {
        throw new Error('Invalid Task Inspector Activity snapshot')
      }
      return snapshot
    },
  }
}

View on GitHub (pinned to 1a708ee577)

Solutions

  1. Verify the taskId exists in the task list before requesting activity.
  2. Refresh the source of the taskId (it may be stale).
  3. Handle TaskNotFound in the UI by clearing the inspector panel rather than crashing.
  4. Ensure you are querying the same session/profile that owns the task.

Example fix

// before
const snap = query.snapshot({ taskId: maybeStaleId }) // throws TaskNotFound

// after — guard before calling
if (!taskList.has(maybeStaleId)) {
  inspector.clear()
  return
}
const snap = query.snapshot({ taskId: maybeStaleId })
Defensive patterns

Strategy: validation

Validate before calling

// Confirm the task exists before requesting its activity snapshot.
if (!taskStore.has(taskId)) {
  inspector.clear()
  return
}
const snap = query.snapshot({ taskId })

Type guard

function taskExists(store: { has(id: string): boolean }, id: string): boolean {
  return store.has(id)
}

Try / catch

try {
  return query.snapshot({ taskId })
} catch (err) {
  if (err instanceof AppError && err.code === ErrorCode.TaskNotFound) {
    inspector.clear()
    return null
  }
  throw err
}

Prevention

When it happens

Trigger: reader.snapshot(taskId) returns null (or undefined) for a taskId that passed assertTaskId. The task identifier is well-formed but unknown to the activity store.

Common situations: Querying an activity snapshot for a task id that was never created, was deleted, belongs to another session/profile, or whose activity log has been pruned; a stale taskId cached in the UI after the task was removed.

Related errors


AI-assisted analysis of agalwood/Motrix@1a708ee577 (2026-08-12). Data as JSON: /api/errors/16b1dc34c7f552da. Report an issue: GitHub.