{"record":{"id":"ebb55a800a01f8b4","repo":"eyaltoledano/claude-task-master","slug":"invalid-tasks-file-ebb55a","errorCode":"INVALID_TASKS_FILE","errorMessage":"No valid tasks found in ${tasksJsonPath}","messagePattern":"No valid tasks found in (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/next-task.js","lineNumber":58,"sourceCode":"\t\t};\n\t}\n\n\t// Define the action function to be executed on cache miss\n\tconst coreNextTaskAction = async () => {\n\t\ttry {\n\t\t\t// Enable silent mode to prevent console logs from interfering with JSON response\n\t\t\tenableSilentMode();\n\n\t\t\tlog.info(`Finding next task from ${tasksJsonPath}`);\n\n\t\t\t// Read tasks data using the provided path\n\t\t\tconst data = readJSON(tasksJsonPath, projectRoot, tag);\n\t\t\tif (!data || !data.tasks) {\n\t\t\t\tdisableSilentMode(); // Disable before return\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: 'INVALID_TASKS_FILE',\n\t\t\t\t\t\tmessage: `No valid tasks found in ${tasksJsonPath}`\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\n\t\t\t// Read the complexity report\n\t\t\tconst complexityReport = readComplexityReport(reportPath);\n\n\t\t\t// Find the next task\n\t\t\tconst nextTask = findNextTask(data.tasks, complexityReport);\n\n\t\t\tif (!nextTask) {\n\t\t\t\tlog.info(\n\t\t\t\t\t'No eligible next task found. All tasks are either completed or have unsatisfied dependencies'\n\t\t\t\t);\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: true,\n\t\t\t\t\tdata: {","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/next-task.js#L40-L76","documentation":"In coreNextTaskAction, after readJSON loads the tasks file, the code checks that the parsed data exists and contains a `tasks` array (next-task.js:53-62). If the file is missing, empty, unparseable, or lacks the expected shape, it returns INVALID_TASKS_FILE. This distinguishes 'file exists but content is not a valid task list' from argument errors.","triggerScenarios":"tasksJsonPath points to a nonexistent file (readJSON returns null), the file contains invalid JSON, or the JSON is valid but has no top-level `tasks` property (e.g. `{\"tasks\": []}` missing, wrong schema, or an empty/newly-initialized project).","commonSituations":"Running next_task before ever running parse-prd (no tasks.json yet); pointing tasksJsonPath at the PRD file instead of tasks.json; a tag context whose tasks.json was deleted or never created; hand-edited tasks.json that broke the schema.","solutions":["Verify the file exists at the exact path in the error message (ls the path shown).","If the project has no tasks yet, run the parse-prd tool on your PRD to generate tasks.json first.","Validate the JSON: it must be an object with a `tasks` array (e.g. `{\"tasks\":[{\"id\":1,...}]}`). Fix or regenerate it.","If using tags, confirm the requested tag's tasks.json exists — the path may include a tag-specific file you did not initialize."],"exampleFix":"// before\nnextTaskDirect({ tasksJsonPath: '/proj/prd.txt' }, log);\n\n// after\nconst tasksPath = '/proj/.taskmaster/tasks/tasks.json';\nconst raw = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (!Array.isArray(raw.tasks)) throw new Error('invalid tasks.json');\nnextTaskDirect({ tasksJsonPath: tasksPath }, log);","handlingStrategy":"validation","validationCode":"const fs = require('fs');\nfunction tasksFileIsValid(p) {\n  if (!fs.existsSync(p)) return false;\n  try {\n    const data = JSON.parse(fs.readFileSync(p, 'utf8'));\n    return Array.isArray(data.tasks);\n  } catch {\n    return false;\n  }\n}\n// call nextTaskDirect only if tasksFileIsValid(tasksJsonPath)","typeGuard":"function isValidTasksData(v) {\n  return typeof v === 'object' && v !== null && Array.isArray(v.tasks);\n}","tryCatchPattern":"const result = await nextTaskDirect({ tasksJsonPath }, log);\nif (!result.success && result.error?.code === 'INVALID_TASKS_FILE') {\n  // regenerate tasks.json via parse_prd before retrying\n}","preventionTips":["Run parse-prd before next-task in any fresh project.","Never point tasksJsonPath at the PRD or report files.","Validate tasks.json after hand edits.","Check tag-specific task files exist for the tag you request."],"tags":["mcp","invalid-file","tasks-json","schema"],"backgroundTag":"invalid-tasks-file","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}