eyaltoledano/claude-task-master · error · TaskMasterError

NO_BRIEF_SELECTED

NO_BRIEF_SELECTED

Error message

No brief selected

What it means

ensureBriefSelected returns a UserContextWithBrief guaranteed to contain a briefId. When the stored context has no brief selected it throws TaskMasterError with code NO_BRIEF_SELECTED and a userMessage telling the user to select a brief via `tm context brief <brief-id|brief-url>`.

Source

Thrown at packages/tm-core/src/modules/auth/managers/auth-manager.ts:371

	/**
	 * Get all tasks for a specific brief
	 */
	async getTasks(briefId: string): Promise<RemoteTask[]> {
		const service = await this.getOrganizationService();
		return service.getTasks(briefId);
	}

	/**
	 * Ensure a brief is selected in the current context
	 * Throws a TaskMasterError if no brief is selected
	 * @param operation - The operation name for error context
	 * @returns The current user context with a guaranteed briefId
	 */
	ensureBriefSelected(operation: string): UserContextWithBrief {
		const context = this.getContext();

		if (!context?.briefId) {
			throw new TaskMasterError(
				'No brief selected',
				ERROR_CODES.NO_BRIEF_SELECTED,
				{
					operation,
					userMessage:
						'No brief selected. Please select a brief first using: tm context brief <brief-id> or tm context brief <brief-url>'
				}
			);
		}

		return context as UserContextWithBrief;
	}
}

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Select a brief first: `tm context brief <brief-id>` or `tm context brief <brief-url>`
  2. Programmatically call authManager.updateContext({ briefId }) before task operations
  3. Catch TaskMasterError code NO_BRIEF_SELECTED and run the brief-selection prompt
  4. Check getContext()?.briefId before invoking brief-dependent operations

Example fix

// before
const task = await tmCore.tasks.get('5'); // throws NO_BRIEF_SELECTED
// after
const ctx = tmCore.auth.getContext();
if (!ctx?.briefId) await tmCore.auth.updateContext({ briefId: 'br_123' });
const task = await tmCore.tasks.get('5');
Defensive patterns

Strategy: validation

Validate before calling

const ctx = tmCore.auth.getContext();
if (!ctx?.briefId) {
  const briefId = await promptBriefSelection();
  await tmCore.auth.updateContext({ briefId });
}

Type guard

function hasBriefSelected(ctx: unknown): ctx is UserContextWithBrief {
  return !!ctx && typeof (ctx as UserContext).briefId === 'string' && (ctx as UserContext).briefId.length > 0;
}

Try / catch

try {
  const task = await tmCore.tasks.get(taskId);
} catch (e) {
  if (e instanceof TaskMasterError && e.code === ERROR_CODES.NO_BRIEF_SELECTED) {
    const briefId = await promptBriefSelection();
    await tmCore.auth.updateContext({ briefId });
    // retry the operation
  } else throw e;
}

Prevention

When it happens

Trigger: Calling task operations that require a brief (getTask, updateTaskStatus, the `context` accessor) when context?.briefId is undefined — i.e. authenticated and org selected, but no brief chosen.

Common situations: After login and org selection the user skipped brief selection; context was cleared; switching machines where the fresh context file lacks briefId; automations assuming a prior interactive selection.

Related errors


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