benbjohnson/litestream · error
too many arguments
Error message
too many arguments
What it means
CLI argument-count error from the `litestream databases` subcommand: positional arguments were supplied but the command accepts none — it reads databases from a config file (or default path) and lists them. Returned by `Run` immediately when `fs.NArg() != 0` after flag parsing.
Source
Thrown at cmd/litestream/databases.go:24
"flag"
"fmt"
"os"
"text/tabwriter"
)
// DatabasesCommand is a command for listing managed databases.
type DatabasesCommand struct{}
// Run executes the command.
func (c *DatabasesCommand) Run(_ context.Context, args []string) (err error) {
fs := flag.NewFlagSet("litestream-databases", flag.ContinueOnError)
configPath, noExpandEnv := registerConfigFlag(fs)
jsonOutput := fs.Bool("json", false, "output raw JSON")
fs.Usage = c.Usage
if err := fs.Parse(args); err != nil {
return err
} else if fs.NArg() != 0 {
return fmt.Errorf("too many arguments")
}
// Load configuration.
if *configPath == "" {
*configPath = DefaultConfigPath()
}
config, err := ReadConfigFile(*configPath, !*noExpandEnv)
if err != nil {
return err
}
databases := make([]DatabaseInfo, 0, len(config.DBs))
for _, dbConfig := range config.DBs {
db, err := NewDBFromConfig(dbConfig)
if err != nil {
return err
}
View on GitHub (pinned to 4ed7a308f6)
Solutions
- Use `litestream databases --config /etc/litestream.yml` instead of a positional path
- Run `litestream databases` with no positional args to list all configured DBs
- Remove stray/empty positional arguments from the command line
- Check `litestream databases --help` for accepted flags
Example fix
// before litestream databases /etc/litestream.yml // after litestream databases --config /etc/litestream.yml
Defensive patterns
Strategy: validation
Validate before calling
// shell pre-check
EXTRA=$((${#@} - $(printf '%s\n' "$@" | grep -c '^--' || true)))
# or simply: call with no positional args
litestream databases --config "$CONFIG" Prevention
- Never pass positional args to litestream databases
- Pass config via --config flag only
- Add smoke tests for command syntax in CI
When it happens
Trigger: Running `litestream databases /etc/litestream.yml` passing the config path positionally instead of via `--config`; old muscle memory from other CLIs; shell scripts appending stray arguments.
Common situations: Users expecting `databases <db-path>` to filter to one database; migration from `litestream db` style commands; quoting errors leaving an empty string argument.
Understand the failure class
Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.
Related errors
- failed to format response: %w
- too many arguments
- must specify at least one replica URL for %s
- too many arguments
- too many arguments
AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06).
Data as JSON: /api/errors/88c547195395dd64.
Report an issue: GitHub.