{"record":{"id":"5c2b15609ee68dc7","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-isgitrepository","errorCode":null,"errorMessage":"projectRoot is required for isGitRepository","messagePattern":"projectRoot is required for isGitRepository","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/common/utils/git-utils.ts","lineNumber":25,"sourceCode":"import { promisify } from 'util';\n\nconst execAsync = promisify(exec);\n\n/**\n * GitHub repository information\n */\nexport interface GitHubRepoInfo {\n\tname: string;\n\towner: { login: string };\n\tdefaultBranchRef: { name: string };\n}\n\n/**\n * Check if the specified directory is inside a git repository\n */\nexport async function isGitRepository(projectRoot: string): Promise<boolean> {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for isGitRepository');\n\t}\n\n\ttry {\n\t\tawait execAsync('git rev-parse --git-dir', { cwd: projectRoot });\n\t\treturn true;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\n/**\n * Synchronous check if directory is in a git repository\n */\nexport function isGitRepositorySync(projectRoot: string): boolean {\n\tif (!projectRoot) {\n\t\treturn false;\n\t}\n","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/common/utils/git-utils.ts#L7-L43","documentation":"isGitRepository runs 'git rev-parse --git-dir' with projectRoot as the working directory. Since that is meaningless without a directory, the function first guards against an empty/undefined projectRoot and throws this error. It signals a programming mistake at the call site rather than a git problem.","triggerScenarios":"Calling isGitRepository(undefined) or isGitRepository('') — typically when a config value or CLI option supplying the project root was never set.","commonSituations":"Calling the utility before project root detection has run; tests that forget to pass a root; config loaders that return an empty root for an uninitialized project; wiring a promise result that resolves to '' on failure.","solutions":["Pass a valid, non-empty absolute path as projectRoot (e.g. process.cwd() or the resolved project directory)","Fix the upstream config resolution that produces an empty/undefined root","Default the argument at the call site: projectRoot || process.cwd()","Add an early assertion in your own code so the empty root is caught with a clearer message"],"exampleFix":"// before\nconst inRepo = await isGitRepository(config.projectRoot);\n// after\nif (!config.projectRoot) throw new Error('Project root not configured');\nconst inRepo = await isGitRepository(config.projectRoot || process.cwd());","handlingStrategy":"validation","validationCode":"import { isAbsolute } from 'path';\nimport { existsSync } from 'fs';\nfunction hasProjectRoot(root) {\n  return typeof root === 'string' && root.length > 0 && isAbsolute(root) && existsSync(root);\n}\nif (!hasProjectRoot(projectRoot)) throw new Error('projectRoot must be a non-empty existing directory');","typeGuard":"function isProjectRoot(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  const inRepo = await isGitRepository(projectRoot);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('projectRoot is required')) {\n    console.error('projectRoot was not set; pass the project directory path.');\n    return false;\n  }\n  throw err;\n}","preventionTips":["Resolve projectRoot once at startup (path.resolve) and pass it everywhere","Validate CLI/config-supplied roots before any git utility call","Never pass possibly-undefined config values straight into git-utils","In tests, always create and pass a real temp directory fixture"],"tags":["git","argument-validation"],"backgroundTag":"missing-required-parameter","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}