{"record":{"id":"df94f7d962bcd12c","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-isondefaultbranch-df94f7","errorCode":null,"errorMessage":"projectRoot is required for isOnDefaultBranch","messagePattern":"projectRoot is required for isOnDefaultBranch","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/utils/git-utils.js","lineNumber":264,"sourceCode":"\n\t\tfor (const defaultName of commonDefaults) {\n\t\t\tif (branches.includes(defaultName)) {\n\t\t\t\treturn defaultName;\n\t\t\t}\n\t\t}\n\n\t\treturn null;\n\t}\n}\n\n/**\n * Check if we're currently on the default branch\n * @param {string} projectRoot - Directory to check (required)\n * @returns {Promise<boolean>} True if on default branch\n */\nasync function isOnDefaultBranch(projectRoot) {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for isOnDefaultBranch');\n\t}\n\n\ttry {\n\t\tconst currentBranch = await getCurrentBranch(projectRoot);\n\t\tconst defaultBranch = await getDefaultBranch(projectRoot);\n\t\treturn currentBranch && defaultBranch && currentBranch === defaultBranch;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\n/**\n * Check and automatically switch tags based on git branch if enabled\n * This runs automatically during task operations, similar to migration\n * @param {string} projectRoot - Project root directory (required)\n * @param {string} tasksPath - Path to tasks.json file\n * @returns {Promise<void>}\n */","sourceCodeStart":246,"sourceCodeEnd":282,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils/git-utils.js#L246-L282","documentation":"isOnDefaultBranch() in git-utils.js requires an explicit projectRoot directory argument to run git commands against. The function throws immediately when the argument is missing, null, or empty because git operations need a working directory to resolve the current and default branches. This is a defensive guard ensuring callers don't silently query the wrong repository.","triggerScenarios":"Calling isOnDefaultBranch() with no argument, undefined, null, or an empty string as the projectRoot parameter.","commonSituations":"Refactoring callers that dropped the projectRoot argument; calling the utility from code that hasn't resolved the project root yet; passing a config object's missing projectRoot field.","solutions":["Pass a resolved absolute projectRoot string as the first argument","Resolve the root via findProjectRoot(process.cwd()) or equivalent before calling","Ensure the calling code path always has a valid projectRoot (validate upstream)"],"exampleFix":"// before\nconst onDefault = await isOnDefaultBranch();\n// after\nconst projectRoot = findProjectRoot(process.cwd());\nconst onDefault = await isOnDefaultBranch(projectRoot);","handlingStrategy":"validation","validationCode":"if (!projectRoot || typeof projectRoot !== 'string') throw new Error('projectRoot must be a non-empty string before calling isOnDefaultBranch');","typeGuard":"function hasProjectRoot(root) { return typeof root === 'string' && root.length > 0; }","tryCatchPattern":"try {\n  const onDefault = await isOnDefaultBranch(projectRoot);\n} catch (err) {\n  if (err.message.includes('projectRoot is required')) {\n    projectRoot = findProjectRoot(process.cwd());\n  } else throw err;\n}","preventionTips":["Always resolve projectRoot early in your command flow and pass it explicitly","Wrap git-utils calls in a helper that resolves root from cwd if missing"],"tags":["git","argument-validation","missing-parameter"],"backgroundTag":"missing-required-argument","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}