eyaltoledano/claude-task-master · error · Error

Failed to get tags: ${error.message}

Error message

Failed to get tags: ${error.message}

What it means

getAllTags() reads tasks.json and uses the format handler to extract the list of tag names. A missing file (ENOENT) returns an empty array; any other read/parse error is wrapped in this error so callers always see a consistent message for tag listing failures.

Source

Thrown at packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts:322

	 */
	async exists(_tag?: string): Promise<boolean> {
		const filePath = this.pathResolver.getTasksPath();
		return this.fileOps.exists(filePath);
	}

	/**
	 * Get all available tags from the single tasks.json file
	 */
	async getAllTags(): Promise<string[]> {
		try {
			const filePath = this.pathResolver.getTasksPath();
			const data = await this.fileOps.readJson(filePath);
			return this.formatHandler.extractTags(data);
		} catch (error: any) {
			if (error.code === 'ENOENT') {
				return []; // File doesn't exist
			}
			throw new Error(`Failed to get tags: ${error.message}`);
		}
	}

	/**
	 * Load metadata from the single tasks.json file for a specific tag
	 */
	async loadMetadata(tag?: string): Promise<TaskMetadata | null> {
		const filePath = this.pathResolver.getTasksPath();
		const resolvedTag = tag || 'master';

		try {
			const rawData = await this.fileOps.readJson(filePath);
			return this.formatHandler.extractMetadata(rawData, resolvedTag);
		} catch (error: any) {
			if (error.code === 'ENOENT') {
				return null;
			}
			throw new Error(`Failed to load metadata: ${error.message}`);

View on GitHub (pinned to c0c98d367c)

Solutions

  1. Check error.message for the underlying cause (parse vs access)
  2. Validate/repair tasks.json, especially the top-level tags structure
  3. Restore tasks.json from git or backup
  4. Fix directory/file permissions for the current process user

Example fix

// before: corrupted tags section
{ "tags": null, "master": { "tasks": [] } }
// after
{ "tags": { "master": { "tasks": [] } } }
Defensive patterns

Strategy: try-catch

Validate before calling

function tagsSectionIsValid(path = '.taskmaster/tasks.json') {
  try {
    const d = JSON.parse(readFileSync(path, 'utf8'));
    return d.tags === undefined || typeof d.tags === 'object';
  } catch { return false; }
}

Type guard

function isGetTagsError(e: unknown): e is Error {
  return e instanceof Error && e.message.startsWith('Failed to get tags:');
}

Try / catch

try {
  const tags = await storage.getAllTags();
} catch (e) {
  if (isGetTagsError(e)) {
    // inspect inner cause; ENOENT cannot reach here (returns []), so it's parse/access
    console.error('Tag listing failed:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: tasks.json contains invalid JSON (readJson parse throws non-ENOENT), permission errors on the file, extractTags encountering an unexpected data shape, or the storage path pointing to a directory.

Common situations: Corrupted tasks.json after a failed concurrent write, tags structure manually removed from the file, running under a user without read access to .taskmaster/, or a custom format handler mismatched with the on-disk format.

Related errors


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