eyaltoledano/claude-task-master · error · Error
Tag ${tag} not found - file doesn't exist
Error message
Tag ${tag} not found - file doesn't exist What it means
deleteTag wraps modifyJson in a try/catch; an ENOENT from the underlying read means tasks.json itself does not exist, and it is rethrown as "Tag X not found - file doesn't exist". This tells you the tag cannot exist because the entire storage file is absent — a bootstrap problem, not a tag-listing problem.
Source
Thrown at packages/tm-core/src/modules/storage/adapters/file-storage/file-storage.ts:743
// Legacy format - remove the tag key
if (tag in data) {
delete data[tag];
return data;
} else {
throw new Error(`Tag ${tag} not found`);
}
} else {
throw new Error(`Tag ${tag} not found in standard format`);
}
});
// Delete the file if we're removing master tag from standard format
if (shouldDeleteFile) {
await this.fileOps.deleteFile(filePath);
}
} catch (error: any) {
if (error.code === 'ENOENT') {
throw new Error(`Tag ${tag} not found - file doesn't exist`);
}
throw error;
}
}
/**
* Rename a tag within the single tasks.json file
* Uses modifyJson for atomic read-modify-write to prevent lost updates
*/
async renameTag(oldTag: string, newTag: string): Promise<void> {
const filePath = this.pathResolver.getTasksPath();
try {
await this.fileOps.modifyJson(filePath, (existingData: any) => {
if (this.formatHandler.detectFormat(existingData) === 'legacy') {
// Legacy format - rename the tag key
if (oldTag in existingData) {
existingData[newTag] = existingData[oldTag];View on GitHub (pinned to c0c98d367c)
Solutions
- Initialize the project to create tasks.json before running tag operations.
- Check that the storage path (cwd / env override) resolves to the directory containing tasks.json.
- Catch this error and short-circuit tag-cleanup routines when the file is missing.
- Restore tasks.json from backup or regenerate it if it was accidentally deleted.
Example fix
// before
await storage.deleteTag('stale');
// after
if (!fs.existsSync(tasksPath)) {
console.warn('tasks.json missing; skipping tag cleanup');
return;
}
await storage.deleteTag('stale'); Defensive patterns
Strategy: validation
Validate before calling
import fs from 'fs';
if (!fs.existsSync(tasksPath)) {
console.warn(`tasks.json missing at ${tasksPath}; skipping tag deletion`);
return;
}
await storage.deleteTag(tag); Type guard
function fileExists(p: string): boolean {
try { return fs.statSync(p).isFile(); } catch { return false; }
} Try / catch
try {
await storage.deleteTag(tag);
} catch (err) {
if (err instanceof Error && err.message.includes("file doesn't exist")) {
console.warn('tasks.json absent — nothing to clean up');
return;
}
throw err;
} Prevention
- Initialize the project before scheduling tag cleanup jobs.
- Run CLI/storage operations from the correct project root.
- Gitignore-aware onboarding: init after clone since tasks.json may not be committed.
- Treat 'file doesn't exist' tag errors as no-ops in cleanup automation.
When it happens
Trigger: storage.deleteTag('x') in a directory with no tasks.json; wrong project root or misconfigured path so the resolver points at a nonexistent file; file deleted between listing and deletion; running tag cleanup in CI on a fresh checkout without init.
Common situations: Gitignored tasks.json missing after clone; CLI run from the wrong working directory; automated cleanup scheduled before project initialization; path env var pointing to a stale location.
Related errors
- Tasks file not found - initialize project first
- VALIDATION_ERROR
- Tag ${tag} not found
- Tag ${oldTag} not found
- CONFIG_MISSING
AI-assisted analysis of eyaltoledano/claude-task-master@c0c98d367c (2026-08-29).
Data as JSON: /api/errors/d47f40db547edcd3.
Report an issue: GitHub.