{"record":{"id":"6ffc1327bbbd148a","repo":"benbjohnson/litestream","slug":"timeout-must-be-greater-than-0-6ffc13","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/register.go","lineNumber":46,"sourceCode":"\t}\n\n\tif fs.NArg() == 0 {\n\t\treturn &usageError{\n\t\t\tmessage: \"database path required\",\n\t\t\thint:    \"litestream register -replica s3://bucket/prefix /path/to/db\",\n\t\t}\n\t}\n\tif fs.NArg() > 1 {\n\t\treturn fmt.Errorf(\"too many arguments\")\n\t}\n\tif *replicaFlag == \"\" {\n\t\treturn &usageError{\n\t\t\tmessage: \"-replica is required\",\n\t\t\thint:    \"litestream register -replica s3://bucket/prefix /path/to/db\",\n\t\t}\n\t}\n\tif *timeout <= 0 {\n\t\treturn fmt.Errorf(\"timeout must be greater than 0\")\n\t}\n\n\tdbPath := fs.Arg(0)\n\treplicaURL := *replicaFlag\n\n\t// Create HTTP client that connects via Unix socket with timeout.\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\treq := litestream.RegisterDatabaseRequest{\n\t\tPath:       dbPath,","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/benbjohnson/litestream/blob/4ed7a308f6271ebfd2b0a6e4b70b03011a37e4a3/cmd/litestream/register.go#L28-L64","documentation":"litestream register validates the -timeout flag before creating its HTTP client for the control socket. A timeout of zero or negative seconds cannot be used as an HTTP client timeout (a zero http.Client.Timeout means no timeout, which is dangerous), so the command rejects it upfront with this plain error.","triggerScenarios":"Running `litestream register -timeout 0 ...` or `-timeout` with a negative value (e.g. scripted invocations that compute the timeout from a variable which defaults to 0, or `-timeout -1` meant as an 'infinite' flag).","commonSituations":"CI scripts that interpolate an unset environment variable into the -timeout flag (expanding to 0); users expecting timeout=0 to mean 'no timeout' as it does for net/http; copy-paste typos in shell wrappers.","solutions":["Omit the -timeout flag entirely to use the default of 30 seconds","Pass a positive integer, e.g. -timeout 60","If the value is computed, guard it: only pass -timeout when the computed value is > 0"],"exampleFix":"// before\nlitestream register -timeout $TIMEOUT -replica s3://bucket/db /path/db\n// after\nTIMEOUT=${TIMEOUT:-30}\nif [ \"$TIMEOUT\" -le 0 ]; then TIMEOUT=30; fi\nlitestream register -timeout \"$TIMEOUT\" -replica s3://bucket/db /path/db","handlingStrategy":"validation","validationCode":"if [ -z \"$TIMEOUT\" ] || [ \"$TIMEOUT\" -le 0 ]; then TIMEOUT=30; fi\nlitestream register -timeout \"$TIMEOUT\" -replica \"$REPLICA\" \"$DB\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass timeout=0 expecting 'unlimited' — omit the flag instead","Default numeric variables with ${VAR:-30} before interpolation","Validate computed timeouts in shell wrappers before invoking"],"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"}