{"record":{"id":"f5b5a4d8d7bc7653","repo":"eyaltoledano/claude-task-master","slug":"targetpath-must-be-a-non-empty-string","errorCode":null,"errorMessage":"targetPath must be a non-empty string","messagePattern":"targetPath must be a non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/manage-gitignore.js","lineNumber":149,"sourceCode":"function addSeparatorIfNeeded(lines) {\n\tif (lines.some((line) => line.trim())) {\n\t\tconst lastLine = lines[lines.length - 1];\n\t\tif (lastLine && lastLine.trim()) {\n\t\t\tlines.push('');\n\t\t}\n\t}\n}\n\n/**\n * Validates input parameters\n * @param {string} targetPath - Path to .gitignore file\n * @param {string} content - Template content\n * @param {boolean} storeTasksInGit - Storage preference\n * @throws {Error} If validation fails\n */\nfunction validateInputs(targetPath, content, storeTasksInGit) {\n\tif (!targetPath || typeof targetPath !== 'string') {\n\t\tthrow new Error('targetPath must be a non-empty string');\n\t}\n\n\tif (!targetPath.endsWith('.gitignore')) {\n\t\tthrow new Error('targetPath must end with .gitignore');\n\t}\n\n\tif (!content || typeof content !== 'string') {\n\t\tthrow new Error('content must be a non-empty string');\n\t}\n\n\tif (typeof storeTasksInGit !== 'boolean') {\n\t\tthrow new Error('storeTasksInGit must be a boolean');\n\t}\n}\n\n/**\n * Creates a new .gitignore file from template\n * @param {string} targetPath - Path to create file at","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/utils/manage-gitignore.js#L131-L167","documentation":"validateInputs in manage-gitignore requires targetPath to be a truthy non-empty string. It throws this error when the path to the target .gitignore file is missing or has the wrong type. This is the first of several sequential checks before the module touches the filesystem.","triggerScenarios":"Calling manageGitignoreFile (via validateInputs) with targetPath undefined/null, an empty string '', a number, or a non-string object (e.g. a URL or Path object).","commonSituations":"Programmatic API misuse where projectRoot was not joined with '.gitignore'; calling the helper before config load completed; passing an object {path: ...} instead of a plain string.","solutions":["Pass an explicit string path ending in .gitignore, e.g. manageGitignoreFile(path.join(projectRoot, '.gitignore'), content, true)","Verify the caller resolves projectRoot correctly before building the path","Use path.join/String() to normalize Path-like values into plain strings"],"exampleFix":"// before\nmanageGitignoreFile(projectRoot, content, store); // wrong: directory, not file path\n// after\nmanageGitignoreFile(path.join(projectRoot, '.gitignore'), content, store);","handlingStrategy":"type-guard","validationCode":"function isGitignorePath(v) { return typeof v === 'string' && v.length > 0; }\nif (!isGitignorePath(targetPath)) throw new TypeError(`targetPath must be a non-empty string, got ${typeof targetPath}`);","typeGuard":"const isNonEmptyString = (v) => typeof v === 'string' && v.length > 0;","tryCatchPattern":"try {\n  manageGitignoreFile(targetPath, content, storeTasksInGit);\n} catch (err) {\n  if (err.message.startsWith('targetPath must be a non-empty string')) {\n    targetPath = path.join(process.cwd(), '.gitignore');\n    manageGitignoreFile(targetPath, content, storeTasksInGit);\n  } else throw err;\n}","preventionTips":["Build the path with path.join(projectRoot, '.gitignore') so it is always a string","Never pass config objects where strings are expected","Validate arguments once in your own wrapper before calling the API"],"tags":["validation","arguments","git"],"backgroundTag":"invalid-argument-type","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}