{"record":{"id":"1523827724944f3f","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-isgitrepositoryroot","errorCode":null,"errorMessage":"projectRoot is required for isGitRepositoryRoot","messagePattern":"projectRoot is required for isGitRepositoryRoot","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/utils/git-utils.js","lineNumber":206,"sourceCode":"\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) {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for isGitRepositoryRoot');\n\t}\n\n\ttry {\n\t\tconst gitRoot = await getGitRepositoryRoot(projectRoot);\n\t\treturn gitRoot && path.resolve(gitRoot) === path.resolve(projectRoot);\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get the default branch name for the repository\n * @param {string} projectRoot - Directory to check (required)\n * @returns {Promise<string|null>} Default branch name or null\n */\nasync function getDefaultBranch(projectRoot) {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for getDefaultBranch');","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils/git-utils.js#L188-L224","documentation":"isGitRepositoryRoot() checks whether projectRoot is exactly the git repository top-level directory by comparing getGitRepositoryRoot()'s result to projectRoot. It throws when projectRoot is falsy, since it delegates to getGitRepositoryRoot which requires it.","triggerScenarios":"Calling isGitRepositoryRoot() with no argument, or with an empty/undefined projectRoot that failed to resolve upstream.","commonSituations":"Deciding whether to write .taskmaster/ at the current location; running from a subdirectory vs repo root; projectRoot not passed through from the CLI command context.","solutions":["Pass an explicit directory: await isGitRepositoryRoot(process.cwd())","Validate projectRoot before calling and default to process.cwd()","Fix the caller that yields an empty value","Wrap in try-catch: the helper also propagates errors from getGitRepositoryRoot"],"exampleFix":"// before\nconst isRoot = await isGitRepositoryRoot(projectRoot);\n// after\nconst isRoot = projectRoot ? await isGitRepositoryRoot(projectRoot) : false;","handlingStrategy":"validation","validationCode":"if (!projectRoot) {\n  throw new TypeError('isGitRepositoryRoot requires a directory to check');\n}\nconst isRoot = await isGitRepositoryRoot(projectRoot);","typeGuard":"function hasProjectRoot(p) {\n  return typeof p === 'string' && p.trim().length > 0;\n}","tryCatchPattern":"try {\n  const isRoot = await isGitRepositoryRoot(projectRoot);\n} catch (err) {\n  if (err.message.includes('projectRoot is required')) {\n    return false;\n  }\n  throw err;\n}","preventionTips":["Default to process.cwd() for root-check operations","Validate the directory exists before the git comparison","Catch propagated errors from getGitRepositoryRoot too","Skip root checks entirely when no project context is available"],"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"}