{"record":{"id":"f3246a034cc2c92d","repo":"eyaltoledano/claude-task-master","slug":"no-current-branch-f3246a","errorCode":"NO_CURRENT_BRANCH","errorMessage":"Could not determine current git branch","messagePattern":"Could not determine current git branch","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"mcp-server/src/core/direct-functions/create-tag-from-branch.js","lineNumber":101,"sourceCode":"\t\t\t\tsuccess: false,\n\t\t\t\terror: {\n\t\t\t\t\tcode: 'NOT_GIT_REPOSITORY',\n\t\t\t\t\tmessage: 'Not in a git repository. Cannot create tag from branch.'\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\n\t\t// Determine branch name\n\t\tlet targetBranch = branchName;\n\t\tif (!targetBranch) {\n\t\t\ttargetBranch = await getCurrentBranch(projectRoot);\n\t\t\tif (!targetBranch) {\n\t\t\t\tlog.error('Could not determine current git branch');\n\t\t\t\tdisableSilentMode();\n\t\t\t\treturn {\n\t\t\t\t\tsuccess: false,\n\t\t\t\t\terror: {\n\t\t\t\t\t\tcode: 'NO_CURRENT_BRANCH',\n\t\t\t\t\t\tmessage: 'Could not determine current git branch'\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\n\t\tlog.info(`Creating tag from git branch: ${targetBranch}`);\n\n\t\t// Prepare options\n\t\tconst options = {\n\t\t\tcopyFromCurrent: copyFromCurrent || false,\n\t\t\tcopyFromTag,\n\t\t\tdescription:\n\t\t\t\tdescription || `Tag created from git branch \"${targetBranch}\"`,\n\t\t\tautoSwitch: autoSwitch || false\n\t\t};\n\n\t\t// Call the createTagFromBranch function","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/eyaltoledano/claude-task-master/blob/c0c98d367c55296bfe69e65680625b6db437af02/mcp-server/src/core/direct-functions/create-tag-from-branch.js#L83-L119","documentation":"Returned by createTagFromBranchDirect when no targetBranch argument was supplied and the current git branch could not be determined from the repository (e.g. detached HEAD or no commits yet). The function needs a branch name to derive the tag; without one it fails with code NO_CURRENT_BRANCH.","triggerScenarios":"Calling create_tag_from_branch without the branchName/targetBranch parameter on a repo in detached HEAD state ('git checkout <sha>'), on an unborn branch (fresh 'git init' with zero commits), or where the git branch command fails in the target directory.","commonSituations":"CI checkouts that pin a commit SHA (GitHub Actions checkout of a tag/SHA), freshly initialized repos with no first commit, or forgetting to pass the branch argument from an MCP client that omits optional fields.","solutions":["Pass the branch explicitly in the tool call (e.g. branchName: 'main').","Ensure HEAD is on a named branch: 'git checkout -b main' or 'git checkout main'.","Make an initial commit so the branch exists: 'git commit --allow-empty -m init'.","Verify with 'git -C <projectRoot> branch --show-current' that a branch name is resolvable before invoking the tool."],"exampleFix":"// before\nawait createTagFromBranchDirect({ projectRoot }); // detached HEAD, no branch arg\n// after\nawait createTagFromBranchDirect({ projectRoot, branchName: currentBranch }); // e.g. 'main'","handlingStrategy":"validation","validationCode":"const { execSync } = require('child_process');\nfunction currentBranch(root) {\n  try {\n    return execSync('git branch --show-current', { cwd: root }).toString().trim() || null;\n  } catch { return null; }\n}\nconst branch = args.branchName || currentBranch(projectRoot);\nif (!branch) throw new Error('No current branch; pass branchName explicitly');","typeGuard":"function hasBranchName(args) {\n  return typeof args.branchName === 'string' && args.branchName.trim().length > 0;\n}","tryCatchPattern":"const res = await createTagFromBranchDirect(args);\nif (!res.success && res.error?.code === 'NO_CURRENT_BRANCH') {\n  // fall back to asking the user for a branch, or `git checkout -b main` first\n}","preventionTips":["Always pass the branchName argument explicitly instead of relying on current-branch inference.","Avoid running integrations from a detached-HEAD checkout; create a named branch first.","Ensure the repo has an initial commit before automating branch-based operations.","Check 'git branch --show-current' output in CI before invoking the tool."],"tags":["git","mcp-server","branch","missing-parameter"],"backgroundTag":"git-detached-head-no-branch","analyzedSha":"c0c98d367c55296bfe69e65680625b6db437af02","analyzedAt":"2026-08-29T02:56:26.071Z","schemaVersion":2},"datasetVersion":"2026-08-29T07:17:48.351Z"}