eyaltoledano/claude-task-master · error · TaskMasterError

AUTHENTICATION_ERROR

AUTHENTICATION_ERROR

Error message

Authentication required for export

What it means

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.

Source

Thrown at packages/tm-core/src/modules/integration/services/export.service.ts:384

 * ExportService handles task export to external systems
 */
export class ExportService {
	private configManager: ConfigManager;
	private authManager: AuthManager;

	constructor(configManager: ConfigManager, authManager: AuthManager) {
		this.configManager = configManager;
		this.authManager = authManager;
	}

	/**
	 * Export tasks to a brief
	 */
	async exportTasks(options: ExportTasksOptions): Promise<ExportResult> {
		const isAuthenticated = await this.authManager.hasValidSession();
		// Validate authentication
		if (!isAuthenticated) {
			throw new TaskMasterError(
				'Authentication required for export',
				ERROR_CODES.AUTHENTICATION_ERROR
			);
		}

		// Get current context
		const context = await this.authManager.getContext();

		// Determine org and brief IDs
		const orgId = options.orgId || context?.orgId;
		const briefId = options.briefId || context?.briefId;

		// Validate we have necessary IDs
		if (!orgId) {
			throw new TaskMasterError(
				'Organization ID is required for export. Use "tm context org" to select one.',
				ERROR_CODES.MISSING_CONFIGURATION
			);

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Run `tm auth login` to establish a valid session, then retry the export.
  2. Check session status with `tm auth status` (or equivalent) to confirm the token is present and not expired.
  3. If the token is expired, re-login to refresh it; clear stale credentials if re-login fails.
  4. In automation, provision credentials via env/CI secrets and authenticate before invoking the export.

Example fix

// before (CLI script)
await tmCore.integration.export.exportTasks({ orgId, briefId });
// after
const auth = tmCore.auth;
if (!(await auth.hasValidSession())) {
  await auth.login(); // or prompt user to run `tm auth login`
}
await tmCore.integration.export.exportTasks({ orgId, briefId });
Defensive patterns

Strategy: try-catch

Validate before calling

const authenticated = await tmCore.auth.hasValidSession();
if (!authenticated) {
  throw new Error('Run `tm auth login` before exporting');
}

Try / catch

try {
  await exportService.exportTasks(options);
} catch (e) {
  if (e instanceof TaskMasterError && e.code === ERROR_CODES.AUTHENTICATION_ERROR) {
    // prompt re-login: `tm auth login`
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Related errors


AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29). Data as JSON: /api/errors/ffedc3e046728f35. Report an issue: GitHub.