{"record":{"id":"ffedc3e046728f35","repo":"eyaltoledano/claude-task-master","slug":"authentication-error-ffedc3","errorCode":"AUTHENTICATION_ERROR","errorMessage":"Authentication required for export","messagePattern":"Authentication required for export","errorType":"error_code","errorClass":"TaskMasterError","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/integration/services/export.service.ts","lineNumber":384,"sourceCode":" * ExportService handles task export to external systems\n */\nexport class ExportService {\n\tprivate configManager: ConfigManager;\n\tprivate authManager: AuthManager;\n\n\tconstructor(configManager: ConfigManager, authManager: AuthManager) {\n\t\tthis.configManager = configManager;\n\t\tthis.authManager = authManager;\n\t}\n\n\t/**\n\t * Export tasks to a brief\n\t */\n\tasync exportTasks(options: ExportTasksOptions): Promise<ExportResult> {\n\t\tconst isAuthenticated = await this.authManager.hasValidSession();\n\t\t// Validate authentication\n\t\tif (!isAuthenticated) {\n\t\t\tthrow new TaskMasterError(\n\t\t\t\t'Authentication required for export',\n\t\t\t\tERROR_CODES.AUTHENTICATION_ERROR\n\t\t\t);\n\t\t}\n\n\t\t// Get current context\n\t\tconst context = await this.authManager.getContext();\n\n\t\t// Determine org and brief IDs\n\t\tconst orgId = options.orgId || context?.orgId;\n\t\tconst briefId = options.briefId || context?.briefId;\n\n\t\t// Validate we have necessary IDs\n\t\tif (!orgId) {\n\t\t\tthrow new TaskMasterError(\n\t\t\t\t'Organization ID is required for export. Use \"tm context org\" to select one.',\n\t\t\t\tERROR_CODES.MISSING_CONFIGURATION\n\t\t\t);","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/integration/services/export.service.ts#L366-L402","documentation":"ExportService.exportTasks() checks authManager.hasValidSession() before performing any export work. If no valid authenticated session exists (not logged in, or the session/token has expired), it throws a TaskMasterError with code AUTHENTICATION_ERROR. This guards the export API, which requires an authenticated user token to attribute exported tasks to a brief.","triggerScenarios":"Calling exportTasks() (directly or via exportFromBriefInput) when the user has never logged in, has logged out, or the stored session token is expired/invalid so authManager.hasValidSession() returns false.","commonSituations":"Running `tm export` in a fresh environment or CI job where `tm auth login` was never run; an expired auth token in a long-lived shell; sharing a workspace where another user's credentials were cleared.","solutions":["Run `tm auth login` to establish a valid session, then retry the export.","Check session status with `tm auth status` (or equivalent) to confirm the token is present and not expired.","If the token is expired, re-login to refresh it; clear stale credentials if re-login fails.","In automation, provision credentials via env/CI secrets and authenticate before invoking the export."],"exampleFix":"// before (CLI script)\nawait tmCore.integration.export.exportTasks({ orgId, briefId });\n// after\nconst auth = tmCore.auth;\nif (!(await auth.hasValidSession())) {\n  await auth.login(); // or prompt user to run `tm auth login`\n}\nawait tmCore.integration.export.exportTasks({ orgId, briefId });","handlingStrategy":"try-catch","validationCode":"const authenticated = await tmCore.auth.hasValidSession();\nif (!authenticated) {\n  throw new Error('Run `tm auth login` before exporting');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await exportService.exportTasks(options);\n} catch (e) {\n  if (e instanceof TaskMasterError && e.code === ERROR_CODES.AUTHENTICATION_ERROR) {\n    // prompt re-login: `tm auth login`\n    return;\n  }\n  throw e;\n}","preventionTips":["Check hasValidSession() before any export/generate call","Run `tm auth login` after switching machines, accounts, or environments","Handle expired tokens proactively by refreshing or re-authenticating on session checks","In CI, provision credentials as a setup step before export commands"],"tags":["authentication","export","session"],"backgroundTag":"authentication-required","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}