{"record":{"id":"0e29a8acf905ec28","repo":"eyaltoledano/claude-task-master","slug":"content-must-be-a-non-empty-string","errorCode":null,"errorMessage":"content must be a non-empty string","messagePattern":"content must be a non-empty string","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/manage-gitignore.js","lineNumber":157,"sourceCode":"\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\n * @param {string[]} templateLines - Adjusted template lines\n * @param {function} log - Logging function\n */\nfunction createNewGitignoreFile(targetPath, templateLines, log) {\n\ttry {\n\t\tfs.writeFileSync(targetPath, templateLines.join('\\n') + '\\n');\n\t\tif (typeof log === 'function') {\n\t\t\tlog('success', `Created ${targetPath} with full template`);","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/utils/manage-gitignore.js#L139-L175","documentation":"validateInputs requires content — the gitignore template text to write — to be a truthy non-empty string. It throws when content is missing, empty, or not a string, preventing the module from creating a blank or invalid .gitignore file.","triggerScenarios":"Calling manageGitignoreFile with content undefined/null, '' , a number, or a non-string value such as a Buffer or an options object.","commonSituations":"Template file failed to load (fs.readFileSync result not converted with toString, or the read threw and a default of undefined was used); asset resolution returned null; refactor passing an options bag where a string was expected.","solutions":["Pass the template string explicitly, e.g. the standard Task Master gitignore snippet","Convert Buffers to strings: content = fs.readFileSync(tplPath, 'utf8')","Fix template/asset loading so a valid string is always produced before calling"],"exampleFix":"// before\nconst content = fs.readFileSync(tplPath); // Buffer, may be rejected\nmanageGitignoreFile(p, content, true);\n// after\nconst content = fs.readFileSync(tplPath, 'utf8');\nmanageGitignoreFile(p, content, true);","handlingStrategy":"validation","validationCode":"if (typeof content !== 'string' || content.length === 0) {\n  content = DEFAULT_GITIGNORE_CONTENT; // supply a template before calling\n}","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('content must be a non-empty string')) {\n    manageGitignoreFile(targetPath, fs.readFileSync(templatePath, 'utf8'), storeTasksInGit);\n  } else throw err;\n}","preventionTips":["Read templates with 'utf8' encoding so you always pass strings, not Buffers","Handle template-load failures instead of letting content become undefined","Keep a hardcoded fallback gitignore snippet in your caller"],"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"}