{"record":{"id":"c280489e177c07a9","repo":"eyaltoledano/claude-task-master","slug":"storetasksingit-must-be-a-boolean","errorCode":null,"errorMessage":"storeTasksInGit must be a boolean","messagePattern":"storeTasksInGit must be a boolean","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/utils/manage-gitignore.js","lineNumber":161,"sourceCode":" * @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`);\n\t\t}\n\t} catch (error) {\n\t\tif (typeof log === 'function') {\n\t\t\tlog('error', `Failed to create ${targetPath}: ${error.message}`);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/src/utils/manage-gitignore.js#L143-L179","documentation":"validateInputs requires storeTasksInGit to be a strict boolean because it decides whether task files are ignored or committed. Non-boolean truthy/falsy values (strings 'true'/'false', 0/1, undefined) are rejected to avoid ambiguous behavior in the generated .gitignore rules.","triggerScenarios":"Calling manageGitignoreFile where the fourth argument is undefined (option not provided), a CLI string flag ('true'/'false' from process.argv or env), or a numeric 0/1.","commonSituations":"Reading the preference from a JSON/env layer that yields strings; forgetting to pass the argument in a programmatic call; CLI parsing that does not coerce --store-tasks to a real boolean.","solutions":["Pass a real boolean: manageGitignoreFile(p, content, storeTasksInGit === true)","Coerce env/CLI strings explicitly: const flag = process.env.TM_STORE_TASKS === 'true'","Ensure the CLI/config layer parses the option with a boolean type (Commander .boolean option, JSON schema default false)"],"exampleFix":"// before\nconst store = process.env.STORE_TASKS_IN_GIT; // 'true' string\nmanageGitignoreFile(p, content, store);\n// after\nconst store = process.env.STORE_TASKS_IN_GIT === 'true';\nmanageGitignoreFile(p, content, store);","handlingStrategy":"type-guard","validationCode":"if (typeof storeTasksInGit !== 'boolean') {\n  storeTasksInGit = storeTasksInGit === 'true' || storeTasksInGit === 1;\n}","typeGuard":"const isBoolean = (v) => typeof v === 'boolean';","tryCatchPattern":"try {\n  manageGitignoreFile(targetPath, content, storeTasksInGit);\n} catch (err) {\n  if (err.message === 'storeTasksInGit must be a boolean') {\n    manageGitignoreFile(targetPath, content, Boolean(storeTasksInGit) && storeTasksInGit !== 'false');\n  } else throw err;\n}","preventionTips":["Coerce env vars and CLI strings to booleans explicitly (=== 'true')","Declare the CLI option as a boolean type in the argument parser","Give config schemas a boolean type with a default of false","Never forward raw env/config values into typed API parameters"],"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"}