{"record":{"id":"db29f12d994cb859","repo":"eyaltoledano/claude-task-master","slug":"not-authenticated-db29f1","errorCode":null,"errorMessage":"Not authenticated","messagePattern":"Not authenticated","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/integration/services/export.service.ts","lineNumber":688,"sourceCode":"\n\t\t\t// Transform tasks to flat structure for API\n\t\t\tconst flatTasks = this.transformTasksForBulkImport(tasks);\n\n\t\t\t// Prepare request body\n\t\t\tconst requestBody = {\n\t\t\t\tsource: 'task-master-cli',\n\t\t\t\toptions: {\n\t\t\t\t\tdryRun: false,\n\t\t\t\t\tstopOnError: false\n\t\t\t\t},\n\t\t\t\taccountId: orgId,\n\t\t\t\ttasks: flatTasks\n\t\t\t};\n\n\t\t\t// Get auth token\n\t\t\tconst accessToken = await this.authManager.getAccessToken();\n\t\t\tif (!accessToken) {\n\t\t\t\tthrow new Error('Not authenticated');\n\t\t\t}\n\n\t\t\t// Make API request\n\t\t\tconst response = await fetch(apiUrl, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: {\n\t\t\t\t\t'Content-Type': 'application/json',\n\t\t\t\t\tAuthorization: `Bearer ${accessToken}`\n\t\t\t\t},\n\t\t\t\tbody: JSON.stringify(requestBody)\n\t\t\t});\n\n\t\t\tif (!response.ok) {\n\t\t\t\tconst errorText = await response.text();\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`API request failed: ${response.status} - ${errorText}`\n\t\t\t\t);\n\t\t\t}","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/integration/services/export.service.ts#L670-L706","documentation":"performExport() fetches an access token via authManager.getAccessToken() right before the HTTP call. Unlike errors 140/148 this is a plain Error (not TaskMasterError) thrown when the token is missing even though an earlier session check passed. It means the service reached the network step without a usable bearer token.","triggerScenarios":"Calling exportTasks() where hasValidSession() returned true but getAccessToken() returns null — e.g. a session record exists but the token was cleared, a partially-completed login, or token storage corrupted between the two checks.","commonSituations":"Race with logout in another process; corrupted or partially-written credential store; custom auth integration that reports a valid session without provisioning an access token; token revoked server-side after the session check.","solutions":["Re-authenticate with `tm auth login` to obtain a fresh access token.","Clear credentials and log in again if the token store appears corrupted.","Ensure no concurrent logout/token-clear runs during the export (e.g. parallel CLI invocations).","Catch this Error and treat it as an auth failure by redirecting the user to login."],"exampleFix":"// before\nawait exportService.exportTasks(options); // may throw raw 'Not authenticated'\n// after\nconst token = await tmCore.auth.getAccessToken();\nif (!token) await tmCore.auth.login();\nawait exportService.exportTasks(options);","handlingStrategy":"try-catch","validationCode":"const accessToken = await tmCore.auth.getAccessToken();\nif (!accessToken) {\n  throw new Error('No access token — run `tm auth login` before exporting');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await exportService.exportTasks(options);\n} catch (e) {\n  if (e instanceof Error && e.message === 'Not authenticated') {\n    // raw Error, not TaskMasterError — recover by re-authenticating\n    await tmCore.auth.login();\n    return exportService.exportTasks(options);\n  }\n  throw e;\n}","preventionTips":["Check getAccessToken() (not just session validity) before long export operations","Avoid running logout/login concurrently with exports in the same profile","Re-login if credentials were provisioned long ago; tokens may have been revoked","In CI, fetch a fresh token at job start rather than reusing cached state"],"tags":["authentication","export","token"],"backgroundTag":"missing-access-token","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}