{"record":{"id":"3dc81953c54814e4","repo":"zylon-ai/private-gpt","slug":"unknown-command-cmd-r","errorCode":null,"errorMessage":"Unknown command: {cmd!r}","messagePattern":"Unknown command: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"private_gpt/cli/main.py","lineNumber":67,"sourceCode":"\n_KNOWN_COMMANDS = [\"serve\", \"run\", \"help\"]\nif _CELERY_AVAILABLE:\n    _KNOWN_COMMANDS.append(\"worker\")\n\n\ndef main() -> None:\n    if len(sys.argv) > 1:\n        cmd = sys.argv[1]\n        if not cmd.startswith(\"-\") and cmd not in _KNOWN_COMMANDS:\n            matches = difflib.get_close_matches(cmd, _KNOWN_COMMANDS, n=1, cutoff=0.6)\n            if matches:\n                typer.echo(\n                    f\"Unknown command: {cmd!r}. Did you mean: {matches[0]!r}?\",\n                    err=True,\n                )\n            else:\n                typer.echo(f\"Unknown command: {cmd!r}\", err=True)\n            raise SystemExit(1)\n    app()\n\n\nif __name__ == \"__main__\":\n    main()\n","sourceCodeStart":49,"sourceCodeEnd":73,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/cli/main.py#L49-L73","documentation":"CLI error from private_gpt/cli/main.py's pre-dispatch guard. If sys.argv[1] is a non-flag token not in _KNOWN_COMMANDS (serve, run, help), the CLI prints 'Unknown command: <cmd>' — with a 'Did you mean' suggestion via difflib when a close match exists — and exits 1 before Typer's app() runs. This exists to give fast, Typer-independent typo feedback.","triggerScenarios":"Running `private-gpt sevre` (typo, suggests 'serve'), `private-gpt start`, or any subcommand name that is not literally serve/run/help. Flags like --help pass through untouched.","commonSituations":"Typos and muscle memory from other CLIs (`start`, `init`, `chat`); scripts pinned to an old CLI version whose command set changed; copy-pasting docs for a different tool.","solutions":["Use a known command: `private-gpt serve`, `private-gpt run`, or `private-gpt help`.","Read the suggestion in the error output — difflib usually proposes the intended command.","Run `private-gpt --help` (a flag, so it bypasses the guard) to list available commands for your version.","Update scripts after upgrading to a CLI whose command set changed."],"exampleFix":"// before\n$ private-gpt sevre\nUnknown command: 'sevre'. Did you mean: 'serve'?\n\n// after\n$ private-gpt serve","handlingStrategy":"validation","validationCode":"import subprocess\n\nKNOWN = {\"serve\", \"run\", \"help\"}\ncmd = \"sevre\"\nif cmd not in KNOWN:\n    import difflib\n    suggestion = difflib.get_close_matches(cmd, KNOWN, n=1)\n    raise SystemExit(f\"Unknown command {cmd!r}{f', did you mean {suggestion[0]!r}?' if suggestion else ''}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `private-gpt --help` to enumerate valid commands.","Pin script subcommands to the installed version's command set.","Read the difflib suggestion in the error output.","Avoid copy-pasting commands from docs of other tools."],"tags":["cli","usage-error","exit-code","typo"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}