{"record":{"id":"dd76ce35d409bd31","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-getremotebranches","errorCode":null,"errorMessage":"projectRoot is required for getRemoteBranches","messagePattern":"projectRoot is required for getRemoteBranches","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/tm-core/src/common/utils/git-utils.ts","lineNumber":124,"sourceCode":"\t\t);\n\t\treturn stdout\n\t\t\t.trim()\n\t\t\t.split('\\n')\n\t\t\t.filter((branch) => branch.length > 0)\n\t\t\t.map((branch) => branch.trim());\n\t} catch (error) {\n\t\treturn [];\n\t}\n}\n\n/**\n * Get list of all remote branches\n */\nexport async function getRemoteBranches(\n\tprojectRoot: string\n): Promise<string[]> {\n\tif (!projectRoot) {\n\t\tthrow new Error('projectRoot is required for getRemoteBranches');\n\t}\n\n\ttry {\n\t\tconst { stdout } = await execAsync(\n\t\t\t'git branch -r --format=\"%(refname:short)\"',\n\t\t\t{ cwd: projectRoot, maxBuffer: 10 * 1024 * 1024 }\n\t\t);\n\t\tconst names = stdout\n\t\t\t.trim()\n\t\t\t.split('\\n')\n\t\t\t.filter((branch) => branch.length > 0 && !branch.includes('HEAD'))\n\t\t\t.map((branch) => branch.replace(/^[^/]+\\//, '').trim());\n\t\treturn Array.from(new Set(names));\n\t} catch (error) {\n\t\treturn [];\n\t}\n}\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/packages/tm-core/src/common/utils/git-utils.ts#L106-L142","documentation":"getRemoteBranches runs 'git branch -r --format=\"%(refname:short)\"' with cwd=projectRoot. Because an empty root is invalid, the function throws this error before invoking git. It is a fail-fast argument validation identical in style to the other git-utils guards.","triggerScenarios":"Calling getRemoteBranches(undefined) or '' — usually projectRoot came from an unset config value; also triggered indirectly via the remoteBranches wrapper.","commonSituations":"CI jobs where the checkout directory variable is empty; scripts executed outside the project directory with no root argument; refactors that dropped the default project-root argument.","solutions":["Provide the repository path explicitly: getRemoteBranches('/path/to/project')","Fall back to process.cwd() at the call site when root is unknown","Repair config resolution so projectRoot is always set before git utilities are used","Check CI environment variables for the workspace path being empty"],"exampleFix":"// before\nawait getRemoteBranches(ciConfig.root); // ciConfig.root was ''\n// after\nawait getRemoteBranches(ciConfig.root || process.env.GITHUB_WORKSPACE || process.cwd());","handlingStrategy":"validation","validationCode":"if (!projectRoot || typeof projectRoot !== 'string') {\n  throw new Error('getRemoteBranches requires a non-empty projectRoot');\n}\n// remote listing also needs remotes; verify after the root check:\nconst remotes = await execAsync('git remote', { cwd: projectRoot });","typeGuard":"function isProjectRoot(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":"try {\n  const remoteBranches = await getRemoteBranches(projectRoot);\n} catch (err) {\n  if (err instanceof Error && err.message.includes('getRemoteBranches')) {\n    console.error('projectRoot not provided; skipping remote branch lookup.');\n    return [];\n  }\n  throw err;\n}","preventionTips":["Ensure CI workspace variables (e.g. GITHUB_WORKSPACE) are non-empty before use","Centralize root resolution in one helper used by all git calls","Add assertions/logging for root values in automation scripts","Test remote-branch flows with a repo that has at least one remote"],"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"}