{"record":{"id":"09546e3a3901a4f3","repo":"gravitational/teleport","slug":"internal-server-error","errorCode":null,"errorMessage":"Internal Server Error","messagePattern":"Internal Server Error","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"lib/limiter/connlimiter.go","lineNumber":63,"sourceCode":"// maxConnections is zero, the limiter performs no tracking and\n// all requests pass through.\nfunc NewConnectionsLimiter(maxConnections int64) *ConnectionsLimiter {\n\treturn &ConnectionsLimiter{\n\t\tmaxConnections: maxConnections,\n\t\tlog:            slog.With(teleport.ComponentKey, \"limiter\"),\n\t\tconnections:    make(map[string]int64),\n\t}\n}\n\n// Wrap wraps an HTTP handler.\nfunc (l *ConnectionsLimiter) Wrap(h http.Handler) {\n\tl.next = h\n}\n\nfunc (l *ConnectionsLimiter) ServeHTTP(w http.ResponseWriter, r *http.Request) {\n\tif l.next == nil {\n\t\tsc := http.StatusInternalServerError\n\t\thttp.Error(w, http.StatusText(sc), sc)\n\t\treturn\n\t}\n\n\tif l.maxConnections == 0 {\n\t\tl.next.ServeHTTP(w, r)\n\t\treturn\n\t}\n\n\tclientIP, err := ratelimit.ExtractClientIP(r)\n\tif err != nil {\n\t\tl.log.WarnContext(context.Background(), \"failed to extract source IP\", \"remote_addr\", r.RemoteAddr)\n\t\tratelimit.ServeHTTPError(w, r, err)\n\t\treturn\n\t}\n\n\tif err := l.AcquireConnection(clientIP); err != nil {\n\t\tl.log.InfoContext(context.Background(), \"limiting request\", \"token\", clientIP, \"error\", err)\n\t\tw.WriteHeader(http.StatusTooManyRequests)","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/gravitational/teleport/blob/1283425b60ec5f60d509ba4c791183d452923ff7/lib/limiter/connlimiter.go#L45-L81","documentation":"ConnectionsLimiter.ServeHTTP writes a plain 'Internal Server Error' (http.StatusText of 500) when it is asked to serve a request but no wrapped handler was configured via Wrap — a misconfigured/misused limiter, not a client-visible runtime condition.","triggerScenarios":"Thrown at lib/limiter/connlimiter.go:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the ConnectionsLimiter is wired with a next handler via Wrap before serving","Check the code path that constructs the limiter middleware chain"],"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"}