{"record":{"id":"5d359a0048e424c7","repo":"benbjohnson/litestream","slug":"unknown-command-s","errorCode":null,"errorMessage":"unknown command: %s","messagePattern":"unknown command: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream-test/main.go","lineNumber":65,"sourceCode":"\n\tif fs.NArg() == 0 || fs.Arg(0) == \"help\" {\n\t\tm.Usage()\n\t\treturn nil\n\t}\n\n\tswitch fs.Arg(0) {\n\tcase \"populate\":\n\t\treturn (&PopulateCommand{Main: m}).Run(ctx, fs.Args()[1:])\n\tcase \"load\":\n\t\treturn (&LoadCommand{Main: m}).Run(ctx, fs.Args()[1:])\n\tcase \"shrink\":\n\t\treturn (&ShrinkCommand{Main: m}).Run(ctx, fs.Args()[1:])\n\tcase \"validate\":\n\t\treturn (&ValidateCommand{Main: m}).Run(ctx, fs.Args()[1:])\n\tcase \"version\":\n\t\treturn (&VersionCommand{Main: m}).Run(ctx, fs.Args()[1:])\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown command: %s\", fs.Arg(0))\n\t}\n}\n\nfunc (m *Main) Usage() {\n\tfmt.Fprintln(m.Stdout, `\nlitestream-test is a testing harness for Litestream database replication.\n\nUsage:\n\n\tlitestream-test <command> [arguments]\n\nCommands:\n\n\tpopulate    Quickly populate a database to a target size\n\tload        Generate continuous load on a database\n\tshrink      Shrink a database by deleting data\n\tvalidate    Validate replication integrity\n\tversion     Show version information","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream-test/main.go#L47-L83","documentation":"The litestream-test CLI dispatches the first positional argument to a known subcommand (load, shrink, validate, version, etc.). If the argument does not match any registered command, Run returns \"unknown command: <name>\". This is a CLI usage error, and the Main's Usage() output lists the valid commands.","triggerScenarios":"Running `litestream-test <something>` where <something> is misspelled, not installed in this build's command table, or omitted entirely (fs.Arg(0) is empty string).","commonSituations":"Typos like `litestream-test popluate`; assuming a subcommand exists when it was added in a newer version; running the bare binary with no subcommand at all.","solutions":["Run `litestream-test` with no arguments to print usage and use an exact subcommand name from the list.","Fix the typo in the subcommand name.","Check `litestream-test version` / rebuild from the expected revision if you expect a subcommand that is not present in this build."],"exampleFix":"// before\nlitestream-test popluate -db ./test.db\n// error: unknown command: popluate\n\n// after\nlitestream-test populate -db ./test.db","handlingStrategy":"validation","validationCode":"const VALID = new Set([\"load\", \"populate\", \"shrink\", \"validate\", \"version\"]);\nconst cmd = process.argv[2];\nif (!VALID.has(cmd)) {\n  throw new Error(`unknown command: ${cmd}. Run 'litestream-test' for usage.`);\n}","typeGuard":"function isKnownCommand(cmd) {\n  return [\"load\", \"populate\", \"shrink\", \"validate\", \"version\"].includes(cmd);\n}","tryCatchPattern":"try {\n  await run(\"litestream-test\", [cmd, ...args]);\n} catch (e) {\n  if (String(e).startsWith(\"unknown command\")) {\n    const usage = await run(\"litestream-test\", []); // prints valid commands\n    console.error(`${e.message}\\n${usage.stdout}`);\n  }\n  throw e;\n}","preventionTips":["Run the bare `litestream-test` command to list valid subcommands before scripting.","Pin the harness version in CI so expected subcommands exist in the build.","Keep subcommand names in a shared constant/script to avoid typos."],"tags":["cli","usage"],"backgroundTag":"invalid-cli-argument","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}