{"record":{"id":"535f4cc15ed99142","repo":"pcottle/learnGitBranching","slug":"git-error-no-general-args","errorCode":null,"errorMessage":"git-error-no-general-args","messagePattern":"git-error-no-general-args","errorType":"validation","errorClass":"GitError","httpStatus":null,"severity":"error","filePath":"src/js/models/commandModel.js","lineNumber":191,"sourceCode":"  getGeneralArgs() {\n    return this.get('generalArgs');\n  }\n\n  setGeneralArgs(args) {\n    this.set('generalArgs', args);\n  }\n\n  setOptionsMap(map) {\n    this.set('supportedMap', map);\n  }\n\n  getOptionsMap() {\n    return this.get('supportedMap');\n  }\n\n  acceptNoGeneralArgs() {\n    if (this.getGeneralArgs().length) {\n      throw new GitError({\n        msg: intl.str('git-error-no-general-args')\n      });\n    }\n  }\n\n  argImpliedHead(args, lower, upper, option) {\n    // our args we expect to be between {lower} and {upper}\n    this.validateArgBounds(args, lower, upper, option);\n    // and if it's one, add a HEAD to the back\n    this.impliedHead(args, lower);\n  }\n\n  oneArgImpliedHead(args, option) {\n    this.argImpliedHead(args, 0, 1, option);\n  }\n\n  twoArgsImpliedHead(args, option) {\n    this.argImpliedHead(args, 1, 2, option);","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/models/commandModel.js#L173-L209","documentation":"CommandModel.acceptNoGeneralArgs() enforces that a command was invoked with zero free-form (positional) arguments. If getGeneralArgs() returns a non-empty array, it throws GitError('git-error-no-general-args'). It's typically called at the top of hg/git command shims that take no loose arguments.","triggerScenarios":"Calling a command that invokes acceptNoGeneralArgs() (e.g. the hg log shim via commandConfig) with trailing positional text, e.g. `hg log -f somebranch` where somebranch becomes a general arg.","commonSituations":"Muscle-memory from git where commands accept ref names; passing a branch name to a command that only accepts options; commands delegating internally that forget to consume their general args first.","solutions":["Remove the extra positional argument from the command","Pass the information via an option flag the command actually supports","If writing a custom command shim, consume/validate general args before calling acceptNoGeneralArgs()"],"exampleFix":"// before\nhg log -f main\n// after\nhg log -f","handlingStrategy":"validation","validationCode":"if (command.getGeneralArgs().length > 0) { reject('this command takes no loose arguments'); }","typeGuard":"function hasNoGeneralArgs(cmdModel) {\n  return cmdModel.getGeneralArgs().length === 0;\n}","tryCatchPattern":"try { command.acceptNoGeneralArgs(); } catch (e) { if (e instanceof GitError) { showMsg('remove extra arguments'); } else throw e; }","preventionTips":["Read each command's syntax before adding trailing tokens","Encode required info in option flags, not positional text, for no-arg commands"],"tags":["argument-validation","command-model","no-general-args"],"backgroundTag":"unexpected-command-arguments","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}