{"record":{"id":"a0d843d1514a8de7","repo":"kubernetes/kubernetes","slug":"dynamic-error-listing-api-services-for-group","errorCode":null,"errorMessage":"<dynamic> error listing API services for group","messagePattern":"<dynamic> error listing API services for group","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_apis.go","lineNumber":144,"sourceCode":"\n// apiGroupHandler serves the `/apis/<group>` endpoint.\ntype apiGroupHandler struct {\n\tcodecs    serializer.CodecFactory\n\tgroupName string\n\n\tlister listers.APIServiceLister\n\n\tdelegate http.Handler\n}\n\nfunc (r *apiGroupHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n\tapiServices, err := r.lister.List(labels.Everything())\n\tif statusErr, ok := err.(*apierrors.StatusError); ok {\n\t\tresponsewriters.WriteRawJSON(int(statusErr.Status().Code), statusErr.Status(), w)\n\t\treturn\n\t}\n\tif err != nil {\n\t\thttp.Error(w, err.Error(), http.StatusInternalServerError)\n\t\treturn\n\t}\n\n\tapiServicesForGroup := []*apiregistrationv1api.APIService{}\n\tfor _, apiService := range apiServices {\n\t\tif apiService.Spec.Group == r.groupName {\n\t\t\tapiServicesForGroup = append(apiServicesForGroup, apiService)\n\t\t}\n\t}\n\n\tif len(apiServicesForGroup) == 0 {\n\t\tr.delegate.ServeHTTP(w, req)\n\t\treturn\n\t}\n\n\tdiscoveryGroup := convertToDiscoveryAPIGroup(apiServicesForGroup)\n\tif discoveryGroup == nil {\n\t\thttp.Error(w, \"\", http.StatusNotFound)","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/kubernetes/kubernetes/blob/94c136764292cc5fac976c0de6587daaea56410f/staging/src/k8s.io/kube-aggregator/pkg/apiserver/handler_apis.go#L126-L162","documentation":"This error comes from the kube-aggregator's /apis/<group> handler (handler_apis.go:144). After checking for a StatusError (which is written as a structured status object at line 140), the handler falls through to a generic error path if r.lister.List() returns a non-Status error, writing err.Error() as HTTP 500. This indicates a low-level failure in the APIService informer cache that is not a standard Kubernetes API status error.","triggerScenarios":"An HTTP GET to /apis/<group> when the informer-backed APIService lister fails with a non-status error — e.g., the cache was never primed, the informer was stopped, or an internal data structure corruption occurred in the indexer.","commonSituations":"Race condition during API server startup where requests arrive before the informer cache syncs; informer factory shutdown during graceful termination; a bug in a custom informer wrapper causing unexpected error types from the underlying cache.","solutions":["Check the API server logs for informer initialization errors around the time of the request","Verify the informer factory has started and the APIService informer has synced before serving traffic","Restart the API server / aggregator if the cache is persistently broken","Review any custom changes to informer lifecycle management in the aggregator"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// Gate the apiGroupHandler on informer cache sync before serving:\nfunc (r *apiGroupHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {\n    if !r.cacheSynced() {\n        http.Error(w, \"cache not synced\", http.StatusServiceUnavailable)\n        return\n    }\n    // ... existing handler logic\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Wait for informer cache sync before registering HTTP handlers","Add a readiness gate that checks informer sync state","Log non-status errors from lister.List to diagnose cache issues early"],"tags":["kubernetes","kube-aggregator","discovery","informer","apiserver"],"backgroundTag":null,"analyzedSha":"94c136764292cc5fac976c0de6587daaea56410f","analyzedAt":"2026-08-08T23:58:27.554Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}