{"record":{"id":"58386fdb14b39c94","repo":"thanos-io/thanos","slug":"s-parameter-is-larger-than-d","errorCode":null,"errorMessage":"'%s' parameter is larger than %d","messagePattern":"'(.+?)' parameter is larger than (.+?)","errorType":"validation","errorClass":null,"httpStatus":400,"severity":"error","filePath":"pkg/receive/handler.go","lineNumber":443,"sourceCode":"\t\tw.WriteHeader(http.StatusServiceUnavailable)\n\t\t_, err := fmt.Fprintf(w, \"Service Unavailable\")\n\t\tif err != nil {\n\t\t\th.logger.Log(\"msg\", \"failed to write to response body\", \"err\", err)\n\t\t}\n\t}\n}\n\nfunc getStatsLimitParameter(r *http.Request) (int, error) {\n\tstatsLimitStr := r.URL.Query().Get(LimitStatsQueryParam)\n\tif statsLimitStr == \"\" {\n\t\treturn DefaultStatsLimit, nil\n\t}\n\tstatsLimit, err := strconv.ParseInt(statsLimitStr, 10, 0)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"unable to parse '%s' parameter: %w\", LimitStatsQueryParam, err)\n\t}\n\tif statsLimit > math.MaxInt {\n\t\treturn 0, fmt.Errorf(\"'%s' parameter is larger than %d\", LimitStatsQueryParam, math.MaxInt)\n\t}\n\treturn int(statsLimit), nil\n}\n\nfunc (h *Handler) getStats(r *http.Request, statsByLabelName string) ([]api.TenantStats, *api.ApiError) {\n\tif !h.isReady() {\n\t\treturn nil, &api.ApiError{Typ: api.ErrorInternal, Err: fmt.Errorf(\"service unavailable\")}\n\t}\n\n\ttenantID := r.Header.Get(h.options.TenantHeader)\n\tgetAllTenantStats := r.FormValue(AllTenantsQueryParam) == \"true\"\n\tif getAllTenantStats && tenantID != \"\" {\n\t\terr := fmt.Errorf(\"using both the %s parameter and the %s header is not supported\", AllTenantsQueryParam, h.options.TenantHeader)\n\t\treturn nil, &api.ApiError{Typ: api.ErrorBadData, Err: err}\n\t}\n\n\tstatsLimit, err := getStatsLimitParameter(r)\n\tif err != nil {","sourceCodeStart":425,"sourceCodeEnd":461,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/receive/handler.go#L425-L461","documentation":"A range guard in getStatsLimitParameter: the parsed limit query parameter exceeds math.MaxInt and therefore cannot be represented as int on the target platform. The request is rejected rather than truncating the limit; the parameter name and bound are included.","triggerScenarios":"Thrown at pkg/receive/handler.go:443 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send a limit_stats value within int range.","Clamp the value client-side before the request."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}