{"record":{"id":"418d0e9b1337425c","repo":"benbjohnson/litestream","slug":"database-path-required","errorCode":null,"errorMessage":"database path required","messagePattern":"database path required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream-test/load.go","lineNumber":57,"sourceCode":"\tmu         sync.Mutex\n}\n\nfunc (c *LoadCommand) Run(ctx context.Context, args []string) error {\n\tfs := flag.NewFlagSet(\"litestream-test load\", flag.ExitOnError)\n\tfs.StringVar(&c.DB, \"db\", \"\", \"Database path (required)\")\n\tfs.IntVar(&c.WriteRate, \"write-rate\", 100, \"Writes per second\")\n\tfs.DurationVar(&c.Duration, \"duration\", 1*time.Minute, \"How long to run\")\n\tfs.StringVar(&c.Pattern, \"pattern\", \"constant\", \"Write pattern (constant, burst, random, wave)\")\n\tfs.IntVar(&c.PayloadSize, \"payload-size\", 1024, \"Size of each write operation in bytes\")\n\tfs.Float64Var(&c.ReadRatio, \"read-ratio\", 0.2, \"Read/write ratio (0.0-1.0)\")\n\tfs.IntVar(&c.Workers, \"workers\", 1, \"Number of concurrent workers\")\n\tfs.Usage = c.Usage\n\tif err := fs.Parse(args); err != nil {\n\t\treturn err\n\t}\n\n\tif c.DB == \"\" {\n\t\treturn fmt.Errorf(\"database path required\")\n\t}\n\n\tif _, err := os.Stat(c.DB); err != nil {\n\t\treturn fmt.Errorf(\"database does not exist: %w\", err)\n\t}\n\n\tslog.Info(\"Starting load generation\",\n\t\t\"db\", c.DB,\n\t\t\"write_rate\", c.WriteRate,\n\t\t\"duration\", c.Duration,\n\t\t\"pattern\", c.Pattern,\n\t\t\"payload_size\", c.PayloadSize,\n\t\t\"read_ratio\", c.ReadRatio,\n\t\t\"workers\", c.Workers,\n\t)\n\n\treturn c.generateLoad(ctx)\n}","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream-test/load.go#L39-L75","documentation":"The litestream-test 'load' command requires a target SQLite database path, supplied via the -db flag. Run returns this error when flag parsing succeeded but the -db value is still the empty string (flag never provided). It's a plain input validation error before any file or database access.","triggerScenarios":"Running 'litestream-test load' (or another subcommand reusing LoadCommand) without the -db flag, e.g. `litestream-test load -write-rate 100`, so c.DB remains \"\" after fs.Parse.","commonSituations":"Forgetting -db when scripting load tests; assuming a positional argument is used instead of the -db flag; copy-pasting examples that omit the flag.","solutions":["Pass the -db flag with the database path: `litestream-test load -db /path/to/db.sqlite`","If scripting, set the flag from a variable and fail fast when the variable is empty","Run `litestream-test load -h` to see the exact flag names and defaults"],"exampleFix":"// before\nlitestream-test load -write-rate 100\n// after\nlitestream-test load -db /data/app.db -write-rate 100","handlingStrategy":"validation","validationCode":"// shell\nif [ -z \"$DB_PATH\" ]; then echo \"-db is required\"; exit 2; fi\nlitestream-test load -db \"$DB_PATH\" \"$@\"","typeGuard":null,"tryCatchPattern":"// Go (calling Run programmatically)\nif err := cmd.Run(ctx, args); err != nil {\n\tif strings.Contains(err.Error(), \"database path required\") {\n\t\treturn fmt.Errorf(\"load: usage: litestream-test load -db <path> [flags]\")\n\t}\n\treturn err\n}","preventionTips":["Always pass -db explicitly; there is no default database path","Use a wrapper script that injects -db from config/env","Check `litestream-test load -h` when unsure of flag names","Validate the DB file exists before invoking to also avoid the follow-on 'database does not exist' error"],"tags":["cli","required-flag","validation"],"backgroundTag":"missing-required-flag","analyzedSha":"4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3","analyzedAt":"2026-09-06T18:29:25.564Z","contentChangedAt":"2026-09-06T18:29:25.564Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}