{"record":{"id":"82bda0b82b55ae66","repo":"gravitational/teleport","slug":"http-statustext-status","errorCode":null,"errorMessage":"http.StatusText(status)","messagePattern":"http\\.StatusText\\(status\\)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/limiter/internal/ratelimit/http.go","lineNumber":48,"sourceCode":"\t\tw.WriteHeader(http.StatusTooManyRequests)\n\t\tw.Write([]byte(err.Error()))\n\t\treturn\n\t}\n\n\tstatus := http.StatusInternalServerError\n\tvar netError net.Error\n\n\tif errors.Is(err, io.EOF) {\n\t\tstatus = http.StatusBadGateway\n\t} else if errors.As(err, &netError) {\n\t\tif netError.Timeout() {\n\t\t\tstatus = http.StatusGatewayTimeout\n\t\t} else {\n\t\t\tstatus = http.StatusBadGateway\n\t\t}\n\t}\n\n\thttp.Error(w, http.StatusText(status), status)\n}\n\nfunc ExtractClientIP(r *http.Request) (string, error) {\n\thost, _, err := net.SplitHostPort(r.RemoteAddr)\n\tif err != nil || host == \"\" {\n\t\treturn \"\", errors.New(\"failed to extract source IP\")\n\t}\n\n\treturn host, nil\n}\n","sourceCodeStart":30,"sourceCodeEnd":59,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/lib/limiter/internal/ratelimit/http.go#L30-L59","documentation":"ServeHTTPError writes the standard status text (e.g. 'Bad Gateway', 'Gateway Timeout') for a mapped HTTP status: io.EOF maps to 502, net timeouts to 504, other net errors to 502, and anything unrecognized to 500. The body deliberately reveals no error detail.","triggerScenarios":"Thrown at lib/limiter/internal/ratelimit/http.go:48 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check server logs for the underlying error behind the status","For 502/504: verify upstream connectivity and timeouts, then retry","For 500: inspect the rate limiter's downstream handler for the failure"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"1283425b60ec5f60d509ba4c791183d452923ff7","analyzedAt":"2026-09-02T04:06:41.601Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}