benbjohnson/litestream · error

too many arguments

Error message

too many arguments

What it means

The `litestream info` command rejects invocation with any positional arguments. After flag parsing, Run checks fs.NArg() and returns this error because info takes no positional arguments; it gathers data from the control socket instead. This is a CLI usage guard so misdirected arguments fail fast rather than being silently ignored.

Source

Thrown at cmd/litestream/info.go:31

	"github.com/benbjohnson/litestream"
)

// InfoCommand represents the command to show daemon information.
type InfoCommand struct{}

// Run executes the info command.
func (c *InfoCommand) Run(_ context.Context, args []string) error {
	fs := flag.NewFlagSet("litestream-info", flag.ContinueOnError)
	socketPath := fs.String("socket", "/var/run/litestream.sock", "control socket path")
	timeout := fs.Int("timeout", 10, "timeout in seconds")
	jsonOutput := fs.Bool("json", false, "output raw JSON")
	fs.Usage = c.Usage
	if err := fs.Parse(args); err != nil {
		return err
	}

	if fs.NArg() > 0 {
		return fmt.Errorf("too many arguments")
	}

	if *timeout <= 0 {
		return fmt.Errorf("timeout must be greater than 0")
	}

	clientTimeout := time.Duration(*timeout) * time.Second
	client := &http.Client{
		Timeout: clientTimeout,
		Transport: &http.Transport{
			DialContext: func(_ context.Context, _, _ string) (net.Conn, error) {
				return net.DialTimeout("unix", *socketPath, clientTimeout)
			},
		},
	}

	resp, err := client.Get("http://localhost/info")
	if err != nil {

View on GitHub (pinned to 4ed7a308f6)

Solutions

  1. Remove all positional arguments and run plain `litestream info` with only flags (e.g. --timeout, --json).
  2. If you meant to pass a database path, note info queries the running daemon via the control socket; edit the config file instead or use the appropriate subcommand.
  3. Check that each flag value is attached correctly (`--flag=value` or `--flag value` exactly once) so no token is left over as positional.

Example fix

// before
$ litestream info /var/lib/app.db
// after
$ litestream info
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2).filter(a => !a.startsWith('-'));
if (args.length > 0) throw new Error('litestream info accepts no positional arguments');

Prevention

When it happens

Trigger: Running `litestream info <something>` where <something> is any extra positional argument, e.g. `litestream info my.db` or a stray flag value that consumed its own flag and left a bare token.

Common situations: Users migrating from older litestream versions where info or similar commands accepted a database path; copy-pasting `litestream info /path/to/db` from docs; a flag written as `--flag value` in a context where it should be `--flag=value`, leaving 'value' as a positional arg.

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


AI-assisted analysis of benbjohnson/litestream@4ed7a308f6 (2026-09-06). Data as JSON: /api/errors/5854ae62353da054. Report an issue: GitHub.