{"record":{"id":"de4291099feb7a11","repo":"benbjohnson/litestream","slug":"database-path-required-de4291","errorCode":null,"errorMessage":"database path required","messagePattern":"database path required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream-test/populate.go","lineNumber":44,"sourceCode":"\tPageSize   int\n}\n\nfunc (c *PopulateCommand) Run(ctx context.Context, args []string) error {\n\tfs := flag.NewFlagSet(\"litestream-test populate\", flag.ExitOnError)\n\tfs.StringVar(&c.DB, \"db\", \"\", \"Database path (required)\")\n\tfs.StringVar(&c.TargetSize, \"target-size\", \"100MB\", \"Target database size (e.g., 1GB, 500MB)\")\n\tfs.IntVar(&c.RowSize, \"row-size\", 1024, \"Average row size in bytes\")\n\tfs.IntVar(&c.BatchSize, \"batch-size\", 1000, \"Rows per transaction\")\n\tfs.IntVar(&c.TableCount, \"table-count\", 1, \"Number of tables to create\")\n\tfs.Float64Var(&c.IndexRatio, \"index-ratio\", 0.2, \"Percentage of columns to index (0.0-1.0)\")\n\tfs.IntVar(&c.PageSize, \"page-size\", 4096, \"SQLite page size in bytes\")\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\ttargetBytes, err := parseSize(c.TargetSize)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"invalid target size: %w\", err)\n\t}\n\n\tslog.Info(\"Starting database population\",\n\t\t\"db\", c.DB,\n\t\t\"target_size\", c.TargetSize,\n\t\t\"row_size\", c.RowSize,\n\t\t\"batch_size\", c.BatchSize,\n\t\t\"table_count\", c.TableCount,\n\t\t\"page_size\", c.PageSize,\n\t)\n\n\tif err := c.populateDatabase(ctx, targetBytes); err != nil {\n\t\treturn fmt.Errorf(\"populate database: %w\", err)","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream-test/populate.go#L26-L62","documentation":"The `litestream-test populate` command requires a database path via the -db flag. After flag parsing, if c.DB is still the empty string, Run returns \"database path required\". The tool never infers a default path, so the flag must be supplied explicitly.","triggerScenarios":"Running `litestream-test populate` without `-db <path>`, or passing `-db` with an empty value (`-db \"\"`).","commonSituations":"Forgetting the flag in scripts; a variable holding the path being empty/unset in shell scripts (e.g., $DB_PATH unset); assuming a default test database path exists.","solutions":["Pass the flag explicitly: `litestream-test populate -db /path/to/test.db`.","In scripts, verify the path variable is non-empty before invoking the command (`: \"${DB_PATH:?DB_PATH not set}\"`).","Run `litestream-test populate -h` to see the required flags."],"exampleFix":"// before (script)\nlitestream-test populate -target-size 1GB\n// error: database path required\n\n// after (script)\n: \"${DB_PATH:?set DB_PATH}\"\nlitestream-test populate -db \"$DB_PATH\" -target-size 1GB","handlingStrategy":"validation","validationCode":"if (!dbPath || dbPath.trim() === \"\") {\n  throw new Error(\"-db is required for litestream-test populate\");\n}","typeGuard":"function hasDbPath(args) {\n  const i = args.indexOf(\"-db\");\n  return i !== -1 && typeof args[i + 1] === \"string\" && args[i + 1] !== \"\";\n}","tryCatchPattern":"try {\n  await run(\"litestream-test\", [\"populate\", ...args]);\n} catch (e) {\n  if (String(e).includes(\"database path required\")) {\n    console.error(\"populate requires -db <path>; got args: \" + args.join(\" \"));\n  }\n  throw e;\n}","preventionTips":["Always pass -db explicitly; never rely on shell variables that may be unset.","Use `${DB_PATH:?}`-style guards in shell scripts to fail fast on empty variables.","Add -db to your team's canonical command templates."],"tags":["cli","missing-argument"],"backgroundTag":"missing-required-argument","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"}