{"record":{"id":"a9e3fc6eb9d5ea5b","repo":"router-for-me/CLIProxyAPI","slug":"must-be-greater-than-zero","errorCode":null,"errorMessage":"must be greater than zero","messagePattern":"must be greater than zero","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"internal/api/handlers/management/logs.go","lineNumber":1227,"sourceCode":"\t}\n\tts, err := strconv.ParseInt(value, 10, 64)\n\tif err != nil || ts <= 0 {\n\t\treturn 0\n\t}\n\treturn ts\n}\n\nfunc parseLimit(raw string) (int, error) {\n\tvalue := strings.TrimSpace(raw)\n\tif value == \"\" {\n\t\treturn 0, nil\n\t}\n\tlimit, err := strconv.Atoi(value)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"must be a positive integer\")\n\t}\n\tif limit <= 0 {\n\t\treturn 0, fmt.Errorf(\"must be greater than zero\")\n\t}\n\treturn limit, nil\n}\n\nfunc parseTimestamp(line string) int64 {\n\tif strings.HasPrefix(line, \"[\") {\n\t\tline = line[1:]\n\t}\n\tif len(line) < 19 {\n\t\treturn 0\n\t}\n\tcandidate := line[:19]\n\tt, err := time.ParseInLocation(\"2006-01-02 15:04:05\", candidate, time.Local)\n\tif err != nil {\n\t\treturn 0\n\t}\n\treturn t.Unix()\n}","sourceCodeStart":1209,"sourceCodeEnd":1245,"githubUrl":"https://github.com/router-for-me/CLIProxyAPI/blob/78f0c4079e3e6273d65d03b5549cffc898703264/internal/api/handlers/management/logs.go#L1209-L1245","documentation":"Returned by parseLimit (logs.go:1227) when the `limit` query parameter parses as an integer but is zero or negative. The limit bounds the number of lines returned; only positive values are meaningful, so limit=0 or limit=-5 is rejected with this distinct message (note: an absent parameter is fine — only an explicitly non-positive value fails).","triggerScenarios":"GET /management/logs?limit=0, ?limit=-1, or a client computing limit as count-pageSize that underflowed to 0.","commonSituations":"Pagination math bugs (page size larger than total producing 0); clients treating 0 as 'unlimited' — the API wants the parameter omitted instead.","solutions":["Send a positive integer, e.g. ?limit=100","If you mean 'no limit', omit the parameter instead of sending 0","Guard client-side: if limit <= 0 do not include it in the query string"],"exampleFix":"// before\nlimit := total - fetched // may be 0\ncurl-ish: /management/logs?limit=\" + strconv.Itoa(limit)\n\n// after\nq := url.Values{}\nif limit > 0 {\n\tq.Set(\"limit\", strconv.Itoa(limit))\n}","handlingStrategy":"validation","validationCode":"q := url.Values{}\nif limit > 0 {\n\tq.Set(\"limit\", strconv.Itoa(limit))\n}\n// never send limit=0 or negative values","typeGuard":"function isPositiveInt(raw string) bool {\n\treturn /^\\d+$/.test(raw) && parseInt(raw, 10) > 0;\n}","tryCatchPattern":null,"preventionTips":["Treat 0 as 'omit the parameter', never send it explicitly","Clamp pagination math results to a minimum of 1 or drop the parameter","Unit-test client query builders for boundary values 0 and -1"],"tags":["logs","query-params","validation","pagination"],"backgroundTag":null,"analyzedSha":"78f0c4079e3e6273d65d03b5549cffc898703264","analyzedAt":"2026-08-15T12:26:37.444Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}