{"record":{"id":"16b1dc34c7f552da","repo":"agalwood/Motrix","slug":"tasknotfound","errorCode":"TaskNotFound","errorMessage":"Task not found: ${taskId}","messagePattern":"Task not found: (.+?)","errorType":"error_code","errorClass":"AppError","httpStatus":null,"severity":"warning","filePath":"src/core/inspector-activity/task-inspector-activity-query.ts","lineNumber":63,"sourceCode":"        return invalid()\n      }\n      const descriptor = Object.getOwnPropertyDescriptor(params, 'taskId')\n      if (!descriptor || !('value' in descriptor)) {\n        return invalid()\n      }\n      let taskId: string\n      try {\n        taskId = assertTaskId(descriptor.value as string)\n      } catch {\n        return invalid()\n      }\n      queryCount += 1\n      if (options.failAfterFirstQuery && queryCount > 1) {\n        throw new Error('deterministic Task Inspector Activity query failure')\n      }\n      const result = reader.snapshot(taskId)\n      if (result == null) {\n        throw new AppError(ErrorCode.TaskNotFound, `Task not found: ${taskId}`)\n      }\n      const snapshot = parseTaskInspectorActivitySnapshot(result, taskId)\n      if (!snapshot) {\n        throw new Error('Invalid Task Inspector Activity snapshot')\n      }\n      return snapshot\n    },\n  }\n}\n","sourceCodeStart":45,"sourceCodeEnd":73,"githubUrl":"https://github.com/agalwood/Motrix/blob/1a708ee57746c434e2c67a44bbf0906a976afea4/src/core/inspector-activity/task-inspector-activity-query.ts#L45-L73","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the taskId exists in the task list before requesting activity.","Refresh the source of the taskId (it may be stale).","Handle TaskNotFound in the UI by clearing the inspector panel rather than crashing.","Ensure you are querying the same session/profile that owns the task."],"exampleFix":"// before\nconst snap = query.snapshot({ taskId: maybeStaleId }) // throws TaskNotFound\n\n// after — guard before calling\nif (!taskList.has(maybeStaleId)) {\n  inspector.clear()\n  return\n}\nconst snap = query.snapshot({ taskId: maybeStaleId })","handlingStrategy":"validation","validationCode":"// Confirm the task exists before requesting its activity snapshot.\nif (!taskStore.has(taskId)) {\n  inspector.clear()\n  return\n}\nconst snap = query.snapshot({ taskId })","typeGuard":"function taskExists(store: { has(id: string): boolean }, id: string): boolean {\n  return store.has(id)\n}","tryCatchPattern":"try {\n  return query.snapshot({ taskId })\n} catch (err) {\n  if (err instanceof AppError && err.code === ErrorCode.TaskNotFound) {\n    inspector.clear()\n    return null\n  }\n  throw err\n}","preventionTips":["Refresh the task list before opening the inspector.","Clear cached taskIds when tasks are deleted.","Handle TaskNotFound gracefully in the UI.","Query the same session/profile that owns the task."],"tags":["inspector","task","not-found","query","activity"],"backgroundTag":null,"analyzedSha":"1a708ee57746c434e2c67a44bbf0906a976afea4","analyzedAt":"2026-08-12T16:18:09.346Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}