{"record":{"id":"8e967dc1c0352327","repo":"eyaltoledano/claude-task-master","slug":"no-tasks-found-in-the-tasks-file","errorCode":null,"errorMessage":"No tasks found in the tasks file","messagePattern":"No tasks found in the tasks file","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/analyze-task-complexity.js","lineNumber":117,"sourceCode":"\t\t\tif (!options._originalTaskCount) {\n\t\t\t\ttry {\n\t\t\t\t\toriginalData = readJSON(tasksPath, projectRoot, tag);\n\t\t\t\t\tif (originalData && originalData.tasks) {\n\t\t\t\t\t\toriginalTaskCount = originalData.tasks.length;\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlog('warn', `Could not read original tasks file: ${e.message}`);\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\toriginalData = readJSON(tasksPath, projectRoot, tag);\n\t\t\tif (\n\t\t\t\t!originalData ||\n\t\t\t\t!originalData.tasks ||\n\t\t\t\t!Array.isArray(originalData.tasks) ||\n\t\t\t\toriginalData.tasks.length === 0\n\t\t\t) {\n\t\t\t\tthrow new Error('No tasks found in the tasks file');\n\t\t\t}\n\t\t\toriginalTaskCount = originalData.tasks.length;\n\n\t\t\t// Filter tasks based on active status\n\t\t\tconst activeStatuses = ['pending', 'blocked', 'in-progress'];\n\t\t\tlet filteredTasks = originalData.tasks.filter((task) =>\n\t\t\t\tactiveStatuses.includes(task.status?.toLowerCase() || 'pending')\n\t\t\t);\n\n\t\t\t// Apply ID filtering if specified\n\t\t\tif (specificIds && specificIds.length > 0) {\n\t\t\t\treportLog(\n\t\t\t\t\t`Filtering tasks by specific IDs: ${specificIds.join(', ')}`,\n\t\t\t\t\t'info'\n\t\t\t\t);\n\t\t\t\tfilteredTasks = filteredTasks.filter((task) =>\n\t\t\t\t\tspecificIds.includes(task.id)\n\t\t\t\t);","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/analyze-task-complexity.js#L99-L135","documentation":"analyzeTaskComplexity() reads the tasks file and requires a tasks array with at least one entry before running the AI complexity analysis. An empty, missing, or malformed tasks payload makes the analysis meaningless, so it fails fast.","triggerScenarios":"Running analyze complexity (CLI `analyze-complexity`, `reanalyze`, or the report/complexity display path) when tasks.json is empty ({ tasks: [] }), corrupted so tasks is not an array, or readJSON returned null due to a parse failure.","commonSituations":"New project where tasks.json was initialized but no tasks added yet; manual edits to tasks.json that broke the array; pointing --file at the wrong JSON file; all tasks in an inactive tag so the raw array exists but validation happens before tag filtering.","solutions":["Add tasks first (add-task or parse-prd) and re-run the complexity analysis.","Validate/repair tasks.json — ensure it parses as JSON with a non-empty tasks array.","Check you are analyzing the correct file/tag; switch to the tag that contains tasks."],"exampleFix":"// before\nnpx task-master analyze-complexity   # tasks.json has { tasks: [] }\n// after\ntask-master add-task --prompt \"Implement auth\" && task-master analyze-complexity","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync('.taskmaster/tasks/tasks.json', 'utf8'));\nif (!Array.isArray(data.tasks) || data.tasks.length === 0) {\n  throw new Error('Add tasks before running complexity analysis');\n}","typeGuard":"function hasTasks(data) {\n  return !!data && Array.isArray(data.tasks) && data.tasks.length > 0;\n}","tryCatchPattern":"try {\n  await analyzeTaskComplexity(options);\n} catch (err) {\n  if (err.message === 'No tasks found in the tasks file') {\n    console.error('tasks.json is empty or invalid — add tasks first.');\n  } else throw err;\n}","preventionTips":["Run parse-prd/add-task before analyze-complexity on a fresh project.","Lint tasks.json after any manual edit.","Check the active tag actually contains tasks before analyzing."],"tags":["empty-state","tasks-file","validation"],"backgroundTag":"empty-tasks-file","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}