{"record":{"id":"51b2b8806abb2612","repo":"benbjohnson/litestream","slug":"timeout-must-be-greater-than-0","errorCode":null,"errorMessage":"timeout must be greater than 0","messagePattern":"timeout must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/litestream/info.go","lineNumber":35,"sourceCode":"type InfoCommand struct{}\n\n// Run executes the info command.\nfunc (c *InfoCommand) Run(_ context.Context, args []string) error {\n\tfs := flag.NewFlagSet(\"litestream-info\", flag.ContinueOnError)\n\tsocketPath := fs.String(\"socket\", \"/var/run/litestream.sock\", \"control socket path\")\n\ttimeout := fs.Int(\"timeout\", 10, \"timeout in seconds\")\n\tjsonOutput := fs.Bool(\"json\", false, \"output raw JSON\")\n\tfs.Usage = c.Usage\n\tif err := fs.Parse(args); err != nil {\n\t\treturn err\n\t}\n\n\tif fs.NArg() > 0 {\n\t\treturn fmt.Errorf(\"too many arguments\")\n\t}\n\n\tif *timeout <= 0 {\n\t\treturn fmt.Errorf(\"timeout must be greater than 0\")\n\t}\n\n\tclientTimeout := time.Duration(*timeout) * time.Second\n\tclient := &http.Client{\n\t\tTimeout: clientTimeout,\n\t\tTransport: &http.Transport{\n\t\t\tDialContext: func(_ context.Context, _, _ string) (net.Conn, error) {\n\t\t\t\treturn net.DialTimeout(\"unix\", *socketPath, clientTimeout)\n\t\t\t},\n\t\t},\n\t}\n\n\tresp, err := client.Get(\"http://localhost/info\")\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to connect to control socket: %w\", err)\n\t}\n\tdefer resp.Body.Close()\n","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/info.go#L17-L53","documentation":"The `litestream info` command validates that the --timeout flag is strictly greater than 0 seconds. A zero or negative timeout would create an http.Client with no usable timeout semantics (0 means no timeout) or an immediately-expiring one, so Run rejects it up front. The value is later converted to time.Duration via time.Duration(*timeout) * time.Second.","triggerScenarios":"Running `litestream info --timeout 0`, `--timeout -5`, or a shell variable expanding to 0/empty-numeric in a script that builds the command line.","commonSituations":"Templated scripts or CI jobs where TIMEOUT env var is unset and defaults to 0; users who think 0 means 'no timeout' and pass 0 explicitly; signed/unsigned confusion when computing the value.","solutions":["Pass a positive integer of seconds, e.g. `litestream info --timeout 30`.","In scripts, default the variable when unset: TIMEOUT=${TIMEOUT:-30} before invoking the command.","Omit the flag entirely to use the built-in default if you only need a reasonable HTTP timeout."],"exampleFix":"// before\n$ litestream info --timeout 0\n// after\n$ litestream info --timeout 30","handlingStrategy":"validation","validationCode":"if (!(Number.isInteger(timeout) && timeout > 0)) {\n  throw new Error('info --timeout must be a positive integer of seconds');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Default timeout variables in scripts: TIMEOUT=${TIMEOUT:-30}.","Remember 0 is rejected (and 0 means no timeout in net/http), so always pass >= 1.","Quote numeric env expansions and validate before interpolation into the command."],"tags":["cli","validation","timeout"],"backgroundTag":"invalid-flag-value","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"}