{"record":{"id":"556d67c1a6a88112","repo":"pcottle/learnGitBranching","slug":"git-error-exist-556d67","errorCode":null,"errorMessage":"git-error-exist","messagePattern":"git-error-exist","errorType":"validation","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/git/index.js","lineNumber":1813,"sourceCode":"\n  if (this.refs[ref]) {\n    return this.refs[ref];\n  }\n  // Commit hashes like C4 are case insensitive\n  if (ref.match(/^c\\d+'*/) && this.refs[ref.toUpperCase()]) {\n    return this.refs[ref.toUpperCase()];\n  }\n\n  // Attempt to split ref string into a reference and a string of ~ and ^ modifiers.\n  var startRef = null;\n  var relative = null;\n  var regex = /^([a-zA-Z0-9]+)(([~\\^]\\d*)*)$/;\n  var matches = regex.exec(ref);\n  if (matches) {\n    startRef = matches[1];\n    relative = matches[2];\n  } else {\n    throw new GitError({\n      msg: intl.str('git-error-exist', {ref: ref})\n    });\n  }\n\n  if (!this.refs[startRef]) {\n    throw new GitError({\n      msg: intl.str('git-error-exist', {ref: ref})\n    });\n  }\n  var commit = this.getCommitFromRef(startRef);\n\n  if (relative) {\n    commit = this.resolveRelativeRef( commit, relative );\n  }\n\n  return commit;\n};\n","sourceCodeStart":1795,"sourceCodeEnd":1831,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L1795-L1831","documentation":"The ref string completely fails to match the ID-plus-optional-relative-suffix grammar ^([a-zA-Z0-9]+)(([~^]\\d*)*)$. This is not a partial match failure — the whole token is malformed (illegal characters, leading ~, empty name, etc.), so resolution cannot even begin.","triggerScenarios":"Passing a ref containing characters outside [a-zA-Z0-9] or a malformed suffix, e.g. 'main-', '~2', 'o/main^', or an empty/whitespace string, to the ref resolver.","commonSituations":"Typos in commands; shell expansion inserting stray characters; programmatically constructed ref names with slashes/dashes that the engine's grammar rejects.","solutions":["Use only alphanumeric ref names in this engine (branches like main, side, not my-branch)","Fix the suffix so it is a valid ~N/^N chain attached to a name","Validate the ref against the regex before calling"],"exampleFix":"// before\nthis.resolveID('o/main^');\n// after\nthis.resolveID('o/main');","handlingStrategy":"type-guard","validationCode":"var RX = /^([a-zA-Z0-9]+)(([~^]\\d*)*)$/;\nif (!RX.test(ref)) throw new Error('malformed ref');","typeGuard":"function isValidRefToken(ref) { return /^([a-zA-Z0-9]+)(([~^]\\d*)*)$/.test(ref); }","tryCatchPattern":null,"preventionTips":["Restrict branch names to alphanumerics in this engine","Sanitize programmatically built ref strings"],"tags":["git","ref","regex-validation","malformed-ref"],"backgroundTag":"git-malformed-refname","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}