{"record":{"id":"f7ef49067484fae6","repo":"eyaltoledano/claude-task-master","slug":"invalid-source-tag","errorCode":"INVALID_SOURCE_TAG","errorMessage":"Source tag \"${sourceTag}\" not found or invalid","messagePattern":"Source tag \"(.+?)\" not found or invalid","errorType":"exception","errorClass":"MoveTaskError","httpStatus":null,"severity":"error","filePath":"scripts/modules/task-manager/move-task.js","lineNumber":640,"sourceCode":" */\nasync function validateMove(tasksPath, taskIds, sourceTag, targetTag, context) {\n\tconst { projectRoot } = context;\n\n\t// Read the raw data without tag resolution to preserve tagged structure\n\tlet rawData = readJSON(tasksPath, projectRoot, sourceTag);\n\n\t// Handle the case where readJSON returns resolved data with _rawTaggedData\n\tif (rawData && rawData._rawTaggedData) {\n\t\trawData = rawData._rawTaggedData;\n\t}\n\n\t// Validate source tag exists\n\tif (\n\t\t!rawData ||\n\t\t!rawData[sourceTag] ||\n\t\t!Array.isArray(rawData[sourceTag].tasks)\n\t) {\n\t\tthrow new MoveTaskError(\n\t\t\tMOVE_ERROR_CODES.INVALID_SOURCE_TAG,\n\t\t\t`Source tag \"${sourceTag}\" not found or invalid`\n\t\t);\n\t}\n\n\t// Create target tag if it doesn't exist\n\tif (!rawData[targetTag]) {\n\t\trawData[targetTag] = { tasks: [] };\n\t\tlog('info', `Created new tag \"${targetTag}\"`);\n\t}\n\n\t// Normalize all IDs to strings once for consistent comparison\n\tconst normalizedSearchIds = taskIds.map((id) => String(id));\n\n\tconst sourceTasks = rawData[sourceTag].tasks.filter((t) => {\n\t\tconst normalizedTaskId = String(t.id);\n\t\treturn normalizedSearchIds.includes(normalizedTaskId);\n\t});","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/task-manager/move-task.js#L622-L658","documentation":"This MoveTaskError with code INVALID_SOURCE_TAG is thrown by validateMove when the source tag is missing from tasks.json, is not an object, or lacks a valid tasks array (rawData[sourceTag].tasks must be an Array). Tag-scoped moves require an existing, well-formed source tag section; the library will not move tasks out of a nonexistent or malformed tag.","triggerScenarios":"Calling move-task across tags where --from/tag name is misspelled; the tag was never created (tags are only created via tag creation or by creating the first task in it); tasks.json was hand-edited so the tag lost its tasks array; casing mismatch ('Backlog' vs 'backlog').","commonSituations":"Scripting cross-tag migrations with hardcoded tag names after a rename; fresh repo where the tag exists in docs but not in tasks.json; manual JSON edits stripping the tasks key; case-sensitivity surprises.","solutions":["Run the tag list command (or inspect tasks.json) to confirm the exact source tag name and spelling.","Create the source tag first if it does not exist, add/keep tasks in it, then move.","Match casing exactly when passing the tag.","Validate the JSON structure: ensure rawData[sourceTag] is an object with a tasks array before calling.","Update automation/config to the renamed tag."],"exampleFix":"// before\nmoveTasksBetweenTags(tasksPath, ['3'], 'backlog', 'in-progress'); // tag 'backlog' missing\n// after\nconst data = readJSON(tasksPath);\nif (!data.backlog || !Array.isArray(data.backlog.tasks)) {\n  throw new Error('Tag \"backlog\" missing; run: task-master tags');\n}\nmoveTasksBetweenTags(tasksPath, ['3'], 'backlog', 'in-progress');","handlingStrategy":"validation","validationCode":"const data = JSON.parse(fs.readFileSync(tasksPath, 'utf8'));\nif (!data || typeof data[sourceTag] !== 'object' || !Array.isArray(data[sourceTag]?.tasks)) {\n  throw new Error(`Source tag \"${sourceTag}\" missing or malformed.`);\n}","typeGuard":"function isValidTagSection(data, tag) {\n  return Boolean(data) && typeof data[tag] === 'object' &&\n    data[tag] !== null && Array.isArray(data[tag].tasks);\n}","tryCatchPattern":"try {\n  await moveTasksBetweenTags(tasksPath, ids, sourceTag, targetTag);\n} catch (e) {\n  if (e.code === 'INVALID_SOURCE_TAG') {\n    console.error(`Tag \"${sourceTag}\" invalid; available: ${Object.keys(readTags())}`);\n  } else throw e;\n}","preventionTips":["List tags (or inspect tasks.json) to confirm exact names including casing before moving.","Create the tag before referencing it in automation.","Never hand-edit tasks.json structure without preserving the {tasks: []} shape per tag.","Centralize tag names in config/constants to avoid typo drift."],"tags":["task-management","tags","validation","move-task"],"backgroundTag":"tag-not-found","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}