{"record":{"id":"ef602e9c33c1dbc7","repo":"gravitational/teleport","slug":"internal-server-error-ef602e","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"lib/limiter/internal/ratelimit/ratelimit.go","lineNumber":101,"sourceCode":"\t\t\tClock: config.Clock,\n\t\t})\n\t\tif err != nil {\n\t\t\treturn nil, trace.Wrap(err)\n\t\t}\n\t\ttl.bucketSets = bucketSets\n\t}\n\n\treturn tl, nil\n}\n\nfunc (tl *TokenLimiter) Wrap(next http.Handler) {\n\ttl.next = next\n}\n\nfunc (tl *TokenLimiter) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tif tl.next == nil {\n\t\tsc := http.StatusInternalServerError\n\t\thttp.Error(w, http.StatusText(sc), sc)\n\t\treturn\n\t}\n\tif tl.defaultRates.Len() == 0 {\n\t\ttl.next.ServeHTTP(w, req)\n\t\treturn\n\t}\n\n\tclientIP, err := ExtractClientIP(req)\n\tif err != nil {\n\t\tServeHTTPError(w, req, err)\n\t\treturn\n\t}\n\n\tif err := tl.consumeRates(clientIP, 1 /* amount */); err != nil {\n\t\ttl.log.InfoContext(context.Background(), \"limiting request\",\n\t\t\t\"method\", req.Method, \"url\", req.URL.String(), \"error\", err)\n\t\tServeHTTPError(w, req, err)\n\t\treturn","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/lib/limiter/internal/ratelimit/ratelimit.go#L83-L119","documentation":"TokenLimiter.ServeHTTP writes a plain 'Internal Server Error' (http.StatusText of 500) when it receives a request but no next handler was configured via Wrap — a misconfigured middleware chain rather than a rate-limit rejection.","triggerScenarios":"Thrown at lib/limiter/internal/ratelimit/ratelimit.go:101 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the TokenLimiter is wrapped around a real handler via Wrap before it serves traffic","Review the middleware construction order in the service setup"],"exampleFix":null,"handlingStrategy":"validation","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"}