{"record":{"id":"833f3151f9708910","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-getgithubrepoinfo-833f31","errorCode":null,"errorMessage":"projectRoot is required for getGitHubRepoInfo","messagePattern":"projectRoot is required for getGitHubRepoInfo","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/utils/git-utils.js","lineNumber":125,"sourceCode":" */\nasync function isGhCliAvailable(projectRoot = null) {\n\ttry {\n\t\tconst options = projectRoot ? { cwd: projectRoot } : {};\n\t\tawait execAsync('gh auth status', options);\n\t\treturn true;\n\t} catch (error) {\n\t\treturn false;\n\t}\n}\n\n/**\n * Get GitHub repository information using gh CLI\n * @param {string} projectRoot - Directory to check (required)\n * @returns {Promise<Object|null>} Repository info or null if not available\n */\nasync function getGitHubRepoInfo(projectRoot) {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for getGitHubRepoInfo');\n\t}\n\n\ttry {\n\t\tconst { stdout } = await execAsync(\n\t\t\t'gh repo view --json name,owner,defaultBranchRef',\n\t\t\t{ cwd: projectRoot }\n\t\t);\n\t\treturn JSON.parse(stdout);\n\t} catch (error) {\n\t\treturn null;\n\t}\n}\n\n/**\n * Sanitize branch name to be a valid tag name\n * @param {string} branchName - Git branch name\n * @returns {string} Sanitized tag name\n */","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils/git-utils.js#L107-L143","documentation":"getGitHubRepoInfo() shells out to 'gh repo view --json ...' with cwd=projectRoot to read repository metadata. It throws when projectRoot is falsy because the gh command must run inside the repository directory.","triggerScenarios":"Calling getGitHubRepoInfo() with a missing/empty projectRoot argument, typically from the 'repoInfo' helper whose caller did not supply a root.","commonSituations":"Fetching GitHub metadata (default branch, owner) in commands that also rely on gh CLI; projectRoot undefined because the command ran outside a Task Master project; argument order mistakes when wrapping the helper.","solutions":["Pass an explicit root: await getGitHubRepoInfo(process.cwd())","Ensure you are in a project directory or set projectRoot from config before calling","Fix the caller (repoInfo wrapper) to forward projectRoot","Note: even with a valid root, a null result means gh CLI is unavailable — check isGhCliAvailable separately"],"exampleFix":"// before\nconst info = await getGitHubRepoInfo();\n// after\nconst info = projectRoot ? await getGitHubRepoInfo(projectRoot) : null;","handlingStrategy":"validation","validationCode":"if (!projectRoot) {\n  throw new TypeError('getGitHubRepoInfo requires a projectRoot');\n}\nconst info = await getGitHubRepoInfo(projectRoot);","typeGuard":"function hasProjectRoot(p) {\n  return typeof p === 'string' && p.trim().length > 0;\n}","tryCatchPattern":"try {\n  const info = await getGitHubRepoInfo(projectRoot);\n} catch (err) {\n  if (err.message.includes('projectRoot is required')) {\n    return null;\n  }\n  throw err;\n}","preventionTips":["Check isGhCliAvailable(projectRoot) and root validity before fetching repo info","Pass process.cwd() explicitly when projectRoot is unknown","Treat null returns (gh unavailable) separately from validation throws","Run gh-dependent features only from inside the repository"],"tags":["git","github","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"}