{"record":{"id":"37543743f745b833","repo":"eyaltoledano/claude-task-master","slug":"id-count-mismatch","errorCode":"ID_COUNT_MISMATCH","errorMessage":"Number of source IDs (${sourceIds.length}) must match number of destination IDs (${destinationIds.length})","messagePattern":"Number of source IDs \\((.+?)\\) must match number of destination IDs \\((.+?)\\)","errorType":"error_code","errorClass":"MoveTaskError","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/move-task.js","lineNumber":124,"sourceCode":" * @param {Object} options - Additional options\n * @param {string} options.projectRoot - Project root directory for tag resolution\n * @param {string} options.tag - Explicit tag to use (optional)\n * @returns {Object} Result object with moved task details\n */\nasync function moveTask(\n\ttasksPath,\n\tsourceId,\n\tdestinationId,\n\tgenerateFiles = false,\n\toptions = {}\n) {\n\tconst { projectRoot, tag } = options;\n\t// Check if we have comma-separated IDs (batch move)\n\tconst sourceIds = sourceId.split(',').map((id) => id.trim());\n\tconst destinationIds = destinationId.split(',').map((id) => id.trim());\n\n\tif (sourceIds.length !== destinationIds.length) {\n\t\tthrow new MoveTaskError(\n\t\t\tMOVE_ERROR_CODES.ID_COUNT_MISMATCH,\n\t\t\t`Number of source IDs (${sourceIds.length}) must match number of destination IDs (${destinationIds.length})`\n\t\t);\n\t}\n\n\t// For batch moves, process each pair sequentially\n\tif (sourceIds.length > 1) {\n\t\tconst results = [];\n\t\tfor (let i = 0; i < sourceIds.length; i++) {\n\t\t\tconst result = await moveTask(\n\t\t\t\ttasksPath,\n\t\t\t\tsourceIds[i],\n\t\t\t\tdestinationIds[i],\n\t\t\t\tfalse, // Don't generate files for each individual move\n\t\t\t\toptions\n\t\t\t);\n\t\t\tresults.push(result);\n\t\t}","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/move-task.js#L106-L142","documentation":"moveTask supports batch moves by pairing comma-separated source and destination IDs (e.g. '5,6,7' -> '9,10,11'). Before processing, it requires both lists to have the same length so each source maps 1:1 to a destination; otherwise it throws MoveTaskError with code ID_COUNT_MISMATCH.","triggerScenarios":"Calling moveTask (or `task-master move --from=5,6 --to=7`) where sourceId.split(',') and destinationId.split(',') yield different counts, e.g. moving 3 sources to 2 destinations.","commonSituations":"Typo in a comma-separated list (dropped or extra ID); generating the lists programmatically and a source being filtered out before the call; misunderstanding that batch move is pairwise, not 'move all into one destination'.","solutions":["Make the destination list the same length as the source list, pairing each source with its destination","If you want multiple tasks moved under one parent, perform separate calls or use the single-ID form with a subtask destination","Trim whitespace and remove empty entries from both lists before calling (',,5' produces empty strings that still count)"],"exampleFix":"// before\ntask-master move --from=\"5,6,7\" --to=\"9,10\"\n// after\ntask-master move --from=\"5,6,7\" --to=\"9,10,11\"","handlingStrategy":"validation","validationCode":"function validateBatchMove(sourceId, destinationId) {\n  const s = sourceId.split(',').map((x) => x.trim()).filter(Boolean);\n  const d = destinationId.split(',').map((x) => x.trim()).filter(Boolean);\n  if (s.length !== d.length) {\n    throw new Error(`Batch move needs equal counts: ${s.length} sources vs ${d.length} destinations`);\n  }\n  return [s, d];\n}","typeGuard":"const isPairedIdList = (s, d) =>\n  s.split(',').filter((x) => x.trim()).length === d.split(',').filter((x) => x.trim()).length;","tryCatchPattern":"try {\n  await moveTask(tasksPath, from, to, false, { projectRoot, tag });\n} catch (err) {\n  if (err.name === 'MoveTaskError' && err.code === 'ID_COUNT_MISMATCH') {\n    console.error('Pair each source ID with a destination ID, e.g. --from=5,6 --to=9,10');\n  } else throw err;\n}","preventionTips":["Build comma-separated lists from arrays and assert equal length before joining","Trim and filter empty segments so 'a,,b' doesn't skew counts","Treat batch move as strictly pairwise — one destination per source","Echo the parsed pairs in CLI output so users see the mapping before execution"],"tags":["cli","validation","batch-operation","task-move"],"backgroundTag":"id-count-mismatch","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}