{"record":{"id":"6895f7d362cd934b","repo":"eyaltoledano/claude-task-master","slug":"storage-error-6895f7","errorCode":"STORAGE_ERROR","errorMessage":"Failed to get task ${taskId}","messagePattern":"Failed to get task (.+?)","errorType":"error_code","errorClass":"TaskMasterError","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/tasks/services/task-service.ts","lineNumber":210,"sourceCode":"\t}\n\n\t/**\n\t * Get a single task by ID - delegates to storage layer\n\t */\n\tasync getTask(taskId: string, tag?: string): Promise<Task | null> {\n\t\t// Use provided tag or get active tag\n\t\tconst activeTag = tag || this.getActiveTag();\n\n\t\ttry {\n\t\t\t// Delegate to storage layer which handles the specific logic for tasks vs subtasks\n\t\t\treturn await this.storage.loadTask(String(taskId), activeTag);\n\t\t} catch (error) {\n\t\t\t// Re-throw all TaskMasterErrors without wrapping\n\t\t\tif (error instanceof TaskMasterError) {\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthrow new TaskMasterError(\n\t\t\t\t`Failed to get task ${taskId}`,\n\t\t\t\tERROR_CODES.STORAGE_ERROR,\n\t\t\t\t{\n\t\t\t\t\toperation: 'getTask',\n\t\t\t\t\tresource: 'task',\n\t\t\t\t\ttaskId: String(taskId),\n\t\t\t\t\ttag: activeTag\n\t\t\t\t},\n\t\t\t\terror as Error\n\t\t\t);\n\t\t}\n\t}\n\n\t/**\n\t * Get tasks filtered by status\n\t */\n\tasync getTasksByStatus(\n\t\tstatus: TaskStatus | TaskStatus[],","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/tasks/services/task-service.ts#L192-L228","documentation":"TaskService.getTask wraps any non-TaskMasterError failure while fetching a task into a TaskMasterError with code STORAGE_ERROR and message 'Failed to get task <taskId>'. The underlying storage read (file or API) threw an unexpected error, which is re-thrown with operation/resource/taskId context attached.","triggerScenarios":"Calling getTask(taskId) (directly or via task/loadTask) when the storage adapter throws — e.g. malformed tasks.json, ENOENT on the tasks file, permission errors, or an API/network failure during the read.","commonSituations":"Corrupted or hand-edited tasks.json; project initialized in a different directory than the process runs in; API session network failures; asking for a task in a tag whose file is missing.","solutions":["Inspect error.details (operation: 'getTask', taskId) and the wrapped cause to find the root storage failure","Verify the tasks file exists and is valid JSON for the given tag","Confirm the process working directory matches the initialized project","If TaskMasterError was already thrown (e.g. NOT_FOUND for the task id), handle it directly — it is re-thrapped unwrapped","Re-authenticate if the cause is an API storage failure"],"exampleFix":"// before\nconst task = await taskService.getTask(5);\n// after\ntry {\n  const task = await taskService.getTask(5);\n} catch (e) {\n  if (e instanceof TaskMasterError && e.code === ERROR_CODES.STORAGE_ERROR) {\n    console.error(`getTask(${e.details?.taskId}) failed:`, e.cause ?? e.message);\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isTaskMasterError(e: unknown): e is TaskMasterError {\n  return e instanceof TaskMasterError;\n}","tryCatchPattern":"try {\n  const task = await taskService.getTask(taskId);\n} catch (e) {\n  if (e instanceof TaskMasterError) {\n    console.error(`getTask failed [${e.code}]:`, e.details);\n  }\n  throw e;\n}","preventionTips":["Initialize TaskService storage before lookups","Validate tasks.json parses (JSON.parse) in CI health checks","Match process cwd to the initialized project directory","Distinguish NOT_FOUND (bad taskId) from STORAGE_ERROR (storage failure) when handling"],"tags":["storage","task-lookup","wrapper-error"],"backgroundTag":"storage-read-failed","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}