{"record":{"id":"ed2c931e345b0301","repo":"eyaltoledano/claude-task-master","slug":"invalid-subtask-count-determined-finalsubtaskco","errorCode":null,"errorMessage":"Invalid subtask count determined (${finalSubtaskCount}), defaulting to 3.","messagePattern":"Invalid subtask count determined \\((.+?)\\), defaulting to 3\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"scripts/modules/task-manager/expand-task.js","lineNumber":203,"sourceCode":"\n\t\t// Determine final subtask count\n\t\tconst explicitNumSubtasks = parseInt(numSubtasks, 10);\n\t\tif (!Number.isNaN(explicitNumSubtasks) && explicitNumSubtasks >= 0) {\n\t\t\tfinalSubtaskCount = explicitNumSubtasks;\n\t\t\tlogger.info(\n\t\t\t\t`Using explicitly provided subtask count: ${finalSubtaskCount}`\n\t\t\t);\n\t\t} else if (taskAnalysis?.recommendedSubtasks) {\n\t\t\tfinalSubtaskCount = parseInt(taskAnalysis.recommendedSubtasks, 10);\n\t\t\tlogger.info(\n\t\t\t\t`Using subtask count from complexity report: ${finalSubtaskCount}`\n\t\t\t);\n\t\t} else {\n\t\t\tfinalSubtaskCount = getDefaultSubtasks(session);\n\t\t\tlogger.info(`Using default number of subtasks: ${finalSubtaskCount}`);\n\t\t}\n\t\tif (Number.isNaN(finalSubtaskCount) || finalSubtaskCount < 0) {\n\t\t\tlogger.warn(\n\t\t\t\t`Invalid subtask count determined (${finalSubtaskCount}), defaulting to 3.`\n\t\t\t);\n\t\t\tfinalSubtaskCount = 3;\n\t\t}\n\n\t\t// Determine prompt content AND system prompt\n\t\t// Calculate the next subtask ID to match current behavior:\n\t\t// - Start from the number of existing subtasks + 1\n\t\t// - This creates sequential IDs: 1, 2, 3, 4...\n\t\t// - Display format shows as parentTaskId.subtaskId (e.g., \"1.1\", \"1.2\", \"2.1\")\n\t\tconst nextSubtaskId = (task.subtasks?.length || 0) + 1;\n\n\t\t// Load prompts using PromptManager\n\t\tconst promptManager = getPromptManager();\n\n\t\t// Check if a codebase analysis provider is being used\n\t\tconst hasCodebaseAnalysisCapability = hasCodebaseAnalysis(\n\t\t\tuseResearch,","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/expand-task.js#L185-L221","documentation":"After resolving the subtask count from the --num-subtasks flag, the complexity report, or the default setting, expandTask sanity-checks it. If the final value is NaN or negative (e.g. a non-numeric complexity value in the report), it warns and hard-codes the count to 3.","triggerScenarios":"finalSubtaskCount ends up NaN or < 0 — typically parseInt(numSubtasks) is NaN and no explicit/default value applied, or the complexity report contained a non-numeric/negative recommendedSubtasks value.","commonSituations":"Passing --num-subtasks=abc; a corrupt complexity report entry with missing/invalid numbers; getDefaultSubtasks returning NaN due to a bad tasks.defaultSubtasks config value.","solutions":["Pass an explicit valid count: task-master expand 5 --num-subtasks=4.","Fix tasks.defaultSubtasks in .taskmaster/config.json to a positive integer.","Regenerate the complexity report ('task-master analyze-complexity') if its recommendedSubtasks values are invalid.","The CLI already self-corrects to 3 subtasks, so this is advisory only."],"exampleFix":"// before\ntask-master expand 5 --num-subtasks=abc\n// after\ntask-master expand 5 --num-subtasks=4","handlingStrategy":"validation","validationCode":"const n = parseInt(numSubtasks, 10);\nif (Number.isNaN(n) || n < 0) {\n  throw new Error(`--num-subtasks must be a non-negative integer, got: ${numSubtasks}`);\n}","typeGuard":"function isValidSubtaskCount(v) {\n  return Number.isInteger(v) && v >= 0;\n}","tryCatchPattern":null,"preventionTips":["Validate --num-subtasks input in wrapper scripts before invoking task-master.","Keep tasks.defaultSubtasks as a positive integer in config.json.","Regenerate the complexity report if its recommendedSubtasks fields look wrong."],"tags":["validation","subtasks","config"],"backgroundTag":"invalid-parameter-value","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}