{"record":{"id":"cb669c7808704df4","repo":"withfig/autocomplete","slug":"failed-parsing-alias","errorCode":null,"errorMessage":"Failed parsing alias","messagePattern":"Failed parsing alias","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/git.ts","lineNumber":4064,"sourceCode":"    return {\n      name: \"git\",\n      subcommands: commands.map((name) => ({\n        name,\n        ...(optionalCommands[name] ?? { description: `Run git-${name}` }),\n      })),\n    };\n  },\n  args: {\n    name: \"alias\",\n    description: \"Custom user defined git alias\",\n    parserDirectives: {\n      alias: async (token, exec) => {\n        const { stdout, status } = await exec({\n          command: \"git\",\n          args: [\"config\", \"--get\", `alias.${token}`],\n        });\n        if (status !== 0) {\n          throw new Error(\"Failed parsing alias\");\n        }\n        return stdout;\n      },\n    },\n    isOptional: true,\n    generators: gitGenerators.aliases,\n  },\n  options: [\n    {\n      name: \"--version\",\n      description: \"Output version\",\n    },\n    {\n      name: \"--help\",\n      description: \"Output help\",\n    },\n    {\n      name: \"-C\",","sourceCodeStart":4046,"sourceCodeEnd":4082,"githubUrl":"https://github.com/withfig/autocomplete/blob/aef52acff84c45edde61ae610cc2c964802b9a38/src/git.ts#L4046-L4082","documentation":"This generator resolves a git alias by running `git config --get alias.<token>`. `git config --get` exits non-zero when the requested key does not exist (or config is unreadable), so the spec throws this Error to signal that the typed token is not a configured git alias.","triggerScenarios":"`git config --get alias.<token>` exits with status !== 0 — i.e. no alias named `token` exists in any config scope, or the git config file cannot be read/parsed.","commonSituations":"User typed a command that is a built-in git command, shell function, or gh alias but not a git config alias; alias defined with different name/casing; repo-level alias expected but defined only globally (or vice versa — though --get searches all scopes); corrupted or unreadable .gitconfig.","solutions":["Run `git config --get alias.<token>` manually to confirm the alias exists","Add the alias with `git config --global alias.<token> '<command>'`","Check `git config --list | grep alias` to see all defined aliases and their exact names","Ensure the git config file is readable and not corrupted (`git config --list` exits 0)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { execSync } from \"child_process\";\nexport function gitAliasExists(token: string): boolean {\n  try {\n    execSync(`git config --get alias.${token}`, { stdio: \"ignore\" });\n    return true;\n  } catch {\n    return false;\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const cmd = await resolveGitAlias(token);\n} catch (err) {\n  if (err instanceof Error && err.message === \"Failed parsing alias\") {\n    // non-zero exit from `git config --get`: token is not a git alias\n    return suggestBuiltins(token); // graceful degradation\n  }\n  throw err;\n}","preventionTips":["Check `git config --get alias.<token>` exit status before calling the generator","List aliases with `git config --get-regexp '^alias\\\\.'` to see valid tokens","Distinguish 'alias not found' (exit 1) from 'config unreadable' (other codes) when handling","Remember the spec is optional (isOptional: true) — treat its failure as empty suggestions"],"tags":["git","cli","config","exit-code"],"backgroundTag":"shell-command-nonzero-exit","analyzedSha":"aef52acff84c45edde61ae610cc2c964802b9a38","analyzedAt":"2026-08-31T11:00:43.303Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}