{"record":{"id":"b364a50a3dc02916","repo":"amir20/dozzle","slug":"minimum-must-be-between-0-and-buffer-size","errorCode":null,"errorMessage":"minimum must be between 0 and buffer size","messagePattern":"minimum must be between 0 and buffer size","errorType":"http","errorClass":null,"httpStatus":400,"severity":"warning","filePath":"internal/web/logs.go","lineNumber":147,"sourceCode":"\tinverse := r.URL.Query().Get(\"inverse\") == \"true\"\n\n\tonlyComplex := r.URL.Query().Has(\"jsonOnly\")\n\teverything := r.URL.Query().Has(\"everything\")\n\tif everything {\n\t\tfrom = time.Time{}\n\t\tto = time.Now()\n\t}\n\n\tminimum := 0\n\tbuffer := utils.NewRingBuffer[*container.LogEvent](500)\n\tif r.URL.Query().Has(\"min\") {\n\t\tminimum, err = strconv.Atoi(r.URL.Query().Get(\"min\"))\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif minimum < 0 || minimum > buffer.Size {\n\t\t\thttp.Error(w, \"minimum must be between 0 and buffer size\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tbuffer = utils.NewRingBuffer[*container.LogEvent](minimum)\n\t}\n\n\tmaxStart := math.MaxInt\n\tif r.URL.Query().Has(\"maxStart\") {\n\t\tmaxStart, err = strconv.Atoi(r.URL.Query().Get(\"maxStart\"))\n\t\tif err != nil {\n\t\t\thttp.Error(w, err.Error(), http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t\tif maxStart < 1 || maxStart > buffer.Size {\n\t\t\thttp.Error(w, \"invalid maxStart\", http.StatusBadRequest)\n\t\t\treturn\n\t\t}\n\t}\n","sourceCodeStart":129,"sourceCodeEnd":165,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/web/logs.go#L129-L165","documentation":"After parsing the `min` query parameter, fetchLogsBetweenDates range-checks it against 0 and the ring buffer capacity (500). Values outside that range get the fixed message \"minimum must be between 0 and buffer size\" with HTTP 400 Bad Request. The buffer cannot be sized smaller than 0 or larger than its default capacity.","triggerScenarios":"GET .../logs?min=-1 or ?min=501 (buffer default size is 500). Any negative value or value exceeding 500 triggers the rejection.","commonSituations":"Clients trying to request 'all logs' with a huge min value; UI sliders misconfigured with negative bounds; code copy-pasted between endpoints with different buffer limits; assuming min is unbounded like a limit parameter.","solutions":["Set min to an integer between 0 and 500 inclusive","Omit `min` to keep the default 500-event buffer","If more than 500 events are needed, use `everything` or adjust from/to date ranges instead of min","Clamp the value client-side before sending"],"exampleFix":"// before\nconst min = 1000; // exceeds buffer size 500\n// after\nconst min = Math.min(Math.max(0, requested), 500);","handlingStrategy":"validation","validationCode":"const min = Number.parseInt(raw, 10);\nif (!Number.isInteger(min) || min < 0 || min > 500) throw new Error(\"min out of range\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Clamp values to 0..500 before sending","Treat min as a buffer hint, not a page size","Omit the parameter for default behavior"],"tags":["http","query-parameter","bad-request","value-out-of-range"],"backgroundTag":"value-out-of-range","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}