{"record":{"id":"659b0089397c6ccb","repo":"eyaltoledano/claude-task-master","slug":"not-authenticated","errorCode":"NOT_AUTHENTICATED","errorMessage":"Not authenticated","messagePattern":"Not authenticated","errorType":"error_code","errorClass":"AuthenticationError","httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/modules/auth/managers/auth-manager.ts","lineNumber":284,"sourceCode":"\t * Get stored user context (userId, email)\n\t */\n\tgetStoredContext() {\n\t\treturn this.sessionManager.getStoredContext();\n\t}\n\n\t/**\n\t * Get the current user context (org/brief selection)\n\t */\n\tgetContext(): UserContext | null {\n\t\treturn this.contextStore.getUserContext();\n\t}\n\n\t/**\n\t * Update the user context (org/brief selection)\n\t */\n\tasync updateContext(context: Partial<UserContext>): Promise<void> {\n\t\tif (!(await this.hasValidSession())) {\n\t\t\tthrow new AuthenticationError('Not authenticated', 'NOT_AUTHENTICATED');\n\t\t}\n\n\t\tthis.contextStore.updateUserContext(context);\n\t}\n\n\t/**\n\t * Clear the user context\n\t */\n\tasync clearContext(): Promise<void> {\n\t\tif (!(await this.hasValidSession())) {\n\t\t\tthrow new AuthenticationError('Not authenticated', 'NOT_AUTHENTICATED');\n\t\t}\n\n\t\tthis.contextStore.clearUserContext();\n\t}\n\n\t/**\n\t * Get the organization service instance","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/modules/auth/managers/auth-manager.ts#L266-L302","documentation":"updateContext persists the org/brief selection into the stored user context, but refuses to do so when no valid authenticated session exists. It throws AuthenticationError with code NOT_AUTHENTICATED rather than silently writing context that would be orphaned.","triggerScenarios":"Calling authManager.updateContext({ orgId, briefId }) when there is no session, the session has expired, or tokens failed refresh (hasValidSession() returns false).","commonSituations":"User never ran `tm auth login`; access token expired and refresh failed; context file was copied to another machine without valid tokens; clock skew invalidating JWT expiry.","solutions":["Run `tm auth` / the login flow to establish a session first","Check session status (e.g. `tm auth status`) before calling updateContext","If the token expired, trigger the refresh/login flow, then retry","Catch AuthenticationError with code NOT_AUTHENTICATED and route the user to login"],"exampleFix":"// before\nawait auth.updateContext({ briefId });\n// after\nif (!(await auth.hasValidSession())) await auth.authenticate();\nawait auth.updateContext({ briefId });","handlingStrategy":"validation","validationCode":"const authenticated = await authManager.hasValidSession();\nif (!authenticated) await runLoginFlow();\nawait authManager.updateContext({ orgId, briefId });","typeGuard":"function isNotAuthenticatedError(e: unknown): e is AuthenticationError {\n  return e instanceof AuthenticationError && e.code === 'NOT_AUTHENTICATED';\n}","tryCatchPattern":"try {\n  await auth.updateContext(ctx);\n} catch (e) {\n  if (isNotAuthenticatedError(e)) {\n    await auth.authenticate();\n    await auth.updateContext(ctx);\n  } else throw e;\n}","preventionTips":["Check hasValidSession() before any context mutation","Proactively refresh or re-login when tokens approach expiry","Never assume a context file copied between machines carries valid sessions","Route users through the login flow on first run of the CLI"],"tags":["auth","session","not-authenticated"],"backgroundTag":"not-authenticated","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}