{"record":{"id":"bc10d8ceeb3bbe99","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-getgitrepositoryroot-bc10d8","errorCode":null,"errorMessage":"projectRoot is required for getGitRepositoryRoot","messagePattern":"projectRoot is required for getGitRepositoryRoot","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/utils/git-utils.js","lineNumber":186,"sourceCode":"\t// Check if it's a reserved branch name that shouldn't become tags\n\tconst reservedBranches = ['main', 'master', 'develop', 'dev', 'HEAD'];\n\tif (reservedBranches.includes(branchName.toLowerCase())) {\n\t\treturn false;\n\t}\n\n\t// Check if sanitized name would be meaningful\n\tconst sanitized = sanitizeBranchNameForTag(branchName);\n\treturn sanitized.length > 0 && sanitized !== 'unknown-branch';\n}\n\n/**\n * Get git repository root directory\n * @param {string} projectRoot - Directory to start search from (required)\n * @returns {Promise<string|null>} Git repository root path or null\n */\nasync function getGitRepositoryRoot(projectRoot) {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for getGitRepositoryRoot');\n\t}\n\n\ttry {\n\t\tconst { stdout } = await execAsync('git rev-parse --show-toplevel', {\n\t\t\tcwd: projectRoot\n\t\t});\n\t\treturn stdout.trim();\n\t} catch (error) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Check if specified directory is the git repository root\n * @param {string} projectRoot - Directory to check (required)\n * @returns {Promise<boolean>} True if directory is git root\n */\nasync function isGitRepositoryRoot(projectRoot) {","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils/git-utils.js#L168-L204","documentation":"getGitRepositoryRoot() runs 'git rev-parse --show-toplevel' with cwd=projectRoot to find the repository root directory. It throws when projectRoot is falsy because the search needs a starting directory.","triggerScenarios":"Calling getGitRepositoryRoot() without arguments or with an empty/undefined projectRoot, e.g. when resolving the repo root from an unresolved project root value.","commonSituations":"Locating the git root to store Task Master state; projectRoot was null because findProjectRoot() failed outside a project; passing an unassigned variable from an async init flow.","solutions":["Pass a starting directory: await getGitRepositoryRoot(process.cwd())","Resolve projectRoot first and handle null before calling","Fix the caller that passes undefined","Guard: return null when projectRoot is absent instead of calling"],"exampleFix":"// before\nconst root = await getGitRepositoryRoot(projectRoot);\n// after\nconst start = projectRoot || process.cwd();\nconst root = await getGitRepositoryRoot(start);","handlingStrategy":"validation","validationCode":"if (!projectRoot) {\n  throw new TypeError('getGitRepositoryRoot requires a starting directory');\n}\nconst gitRoot = await getGitRepositoryRoot(projectRoot);","typeGuard":"function hasProjectRoot(p) {\n  return typeof p === 'string' && p.trim().length > 0;\n}","tryCatchPattern":"try {\n  const gitRoot = await getGitRepositoryRoot(projectRoot);\n} catch (err) {\n  if (err.message.includes('projectRoot is required')) {\n    return null;\n  }\n  throw err;\n}","preventionTips":["Start the search from process.cwd() when projectRoot is unresolved","Validate findProjectRoot() output before delegating to git-utils","Handle the null return (not in a git repo) separately","Avoid passing variables assigned in async flows before they are set"],"tags":["git","argument-validation","project-root"],"backgroundTag":"missing-required-argument","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}