{"record":{"id":"b847f7cbdabdc0b1","repo":"benbjohnson/litestream","slug":"too-many-arguments-b847f7","errorCode":null,"errorMessage":"too many arguments","messagePattern":"too many arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/restore.go","lineNumber":51,"sourceCode":"\tifDBNotExists := fs.Bool(\"if-db-not-exists\", false, \"\")\n\tifReplicaExists := fs.Bool(\"if-replica-exists\", false, \"\")\n\ttimestampStr := fs.String(\"timestamp\", \"\", \"timestamp\")\n\tdryRun := fs.Bool(\"dry-run\", false, \"print restore plan without writing\")\n\tforce := fs.Bool(\"force\", false, \"overwrite existing output database\")\n\tjsonOutput := fs.Bool(\"json\", false, \"output raw JSON\")\n\tfs.BoolVar(&opt.Follow, \"f\", false, \"follow mode\")\n\tfs.DurationVar(&opt.FollowInterval, \"follow-interval\", opt.FollowInterval, \"polling interval for follow mode\")\n\tintegrityCheck := fs.String(\"integrity-check\", \"none\", \"post-restore integrity check: none, quick, or full\")\n\tfs.Usage = c.Usage\n\tif err := fs.Parse(args); err != nil {\n\t\treturn err\n\t} else if fs.NArg() == 0 || fs.Arg(0) == \"\" {\n\t\treturn &usageError{\n\t\t\tmessage: \"database path or replica URL required\",\n\t\t\thint:    \"litestream restore -o /path/to/db s3://bucket/prefix\",\n\t\t}\n\t} else if fs.NArg() > 1 {\n\t\treturn fmt.Errorf(\"too many arguments\")\n\t}\n\n\tlogOutput := os.Stdout\n\tif *jsonOutput {\n\t\tlogOutput = os.Stderr\n\t}\n\tinternal.InitLog(logOutput, \"INFO\", \"text\", false)\n\n\t// When follow mode is enabled, set up signal handling so Ctrl+C stops\n\t// the follow loop cleanly.\n\tif opt.Follow {\n\t\tch := signalChan()\n\t\tcancelCtx, cancel := context.WithCancel(ctx)\n\t\tgo func() {\n\t\t\tselect {\n\t\t\tcase <-ch:\n\t\t\t\tcancel()\n\t\t\tcase <-cancelCtx.Done():","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/restore.go#L33-L69","documentation":"`litestream restore` accepts at most one positional argument — either a database path or a replica URL. If more than one positional argument is supplied on the command line, the command rejects it with this plain error instead of guessing which target you meant. It is pure argument-count validation performed in Restore's Run before any work starts.","triggerScenarios":"`litestream restore -o out.db /path/to/db s3://bucket/prefix` or any invocation with two or more positional args, e.g. passing both a local db path and a replica URL together, or unquoted paths containing spaces.","commonSituations":"Users combining the two targeting styles (path + URL) in one command; shell word-splitting of unquoted paths with spaces; copy-pasting example commands that include both forms.","solutions":["Use exactly one positional arg: either the db path (with -config if needed) or the replica URL, never both","Quote paths containing spaces: litestream restore -o out.db \"/path/with space/db.sqlite\"","If you need to restore from a specific replica of a configured db, use the URL form alone: litestream restore -o out.db s3://bucket/prefix"],"exampleFix":"// before\nlitestream restore -o out.db /var/lib/db/app.db s3://bucket/prefix\n// after\nlitestream restore -o out.db s3://bucket/prefix","handlingStrategy":"validation","validationCode":"args := flag.Args()\nif len(args) > 1 {\n    return fmt.Errorf(\"restore takes exactly one positional arg (db path or replica URL), got %d\", len(args))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Quote paths with spaces in shell scripts","Never combine db path and replica URL in one restore invocation","Validate arg counts in wrapper scripts before exec'ing litestream"],"tags":["cli","arguments","restore"],"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"}