{"record":{"id":"8843366f82611cac","repo":"eyaltoledano/claude-task-master","slug":"projectroot-is-required-for-getremotebranches-884336","errorCode":null,"errorMessage":"projectRoot is required for getRemoteBranches","messagePattern":"projectRoot is required for getRemoteBranches","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/modules/utils/git-utils.js","lineNumber":85,"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 * @param {string} projectRoot - Directory to check (required)\n * @returns {Promise<string[]>} Array of remote branch names (without remote prefix)\n */\nasync function getRemoteBranches(projectRoot) {\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 }\n\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 && !branch.includes('HEAD'))\n\t\t\t.map((branch) => branch.replace(/^origin\\//, '').trim());\n\t} catch (error) {\n\t\treturn [];\n\t}\n}\n\n/**","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/scripts/modules/utils/git-utils.js#L67-L103","documentation":"getRemoteBranches() runs 'git branch -r --format=\"%(refname:short)\"' with cwd=projectRoot to list remote-tracking branches. It throws when projectRoot is falsy because the git command requires a working directory.","triggerScenarios":"Calling getRemoteBranches() with no argument or with null/undefined/'' projectRoot, e.g. when root auto-detection returned nothing upstream.","commonSituations":"Listing remote branches for PR/PRD workflows from a directory where projectRoot was never established; passing the wrong variable (undefined) due to destructuring; CI environments without the project path set.","solutions":["Pass an explicit root: await getRemoteBranches(process.cwd())","Resolve projectRoot (findProjectRoot or config) before calling and fail with a clear message if absent","Fix the destructuring/caller that drops the argument","Guard: only call when projectRoot is truthy"],"exampleFix":"// before\nconst remotes = await getRemoteBranches(projectRoot);\n// after\nconst root = projectRoot ?? findProjectRoot(process.cwd());\nif (!root) throw new Error('Could not determine project root');\nconst remotes = await getRemoteBranches(root);","handlingStrategy":"validation","validationCode":"if (!projectRoot) {\n  throw new TypeError('getRemoteBranches requires a projectRoot');\n}\nconst remotes = await getRemoteBranches(projectRoot);","typeGuard":"function hasProjectRoot(p) {\n  return typeof p === 'string' && p.trim().length > 0;\n}","tryCatchPattern":"try {\n  const remotes = await getRemoteBranches(projectRoot);\n} catch (err) {\n  if (err.message.includes('projectRoot is required')) {\n    return [];\n  }\n  throw err;\n}","preventionTips":["Always pass an explicit project root to remote-branch helpers","Check root detection results before chaining git calls","In CI, export/derive the project path explicitly","Return a sane default ([]) on validation failure instead of crashing"],"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"}