{"record":{"id":"c36e0c7de3972d2f","repo":"GoogleContainerTools/skaffold","slug":"getting-server-resources-for-group-version-w","errorCode":null,"errorMessage":"getting server resources for group version: %w","messagePattern":"getting server resources for group version: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/util/util.go","lineNumber":162,"sourceCode":"\t\t\t}\n\t\t}\n\t}\n\tlog.Entry(context.TODO()).Infof(\"manifests hydration will take place in %v\\n\", hydratedDir)\n\treturn hydratedDir, nil\n}\n\nfunc isDirEmpty(dir string) bool {\n\tf, _ := os.Open(dir)\n\tdefer f.Close()\n\t_, err := f.Readdirnames(1)\n\treturn err == io.EOF\n}\n\n// GroupVersionResource returns the first `GroupVersionResource` for the given `GroupVersionKind`.\nfunc GroupVersionResource(disco discovery.DiscoveryInterface, gvk schema.GroupVersionKind) (bool, schema.GroupVersionResource, error) {\n\tresources, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String())\n\tif err != nil {\n\t\treturn false, schema.GroupVersionResource{}, fmt.Errorf(\"getting server resources for group version: %w\", err)\n\t}\n\n\tfor _, r := range resources.APIResources {\n\t\tif r.Kind == gvk.Kind {\n\t\t\treturn r.Namespaced, schema.GroupVersionResource{\n\t\t\t\tGroup:    gvk.Group,\n\t\t\t\tVersion:  gvk.Version,\n\t\t\t\tResource: r.Name,\n\t\t\t}, nil\n\t\t}\n\t}\n\n\treturn false, schema.GroupVersionResource{}, fmt.Errorf(\"could not find resource for %s\", gvk.String())\n}\n\nfunc GetManifestsFromHydratedManifests(ctx context.Context, hydratedManifests []string) (manifest.ManifestList, error) {\n\tvar manifests manifest.ManifestList\n\tfor _, path := range hydratedManifests {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/util/util.go#L144-L180","documentation":"GroupVersionResource queries the Kubernetes API server's discovery endpoint (ServerResourcesForGroupVersion) to map a GroupVersionKind to its corresponding GroupVersionResource. If the discovery call fails — network problem, wrong API group/version, or server rejecting the request — the error is wrapped with this message. Callers Select and updateRuntimeObject rely on this mapping to build typed clients.","triggerScenarios":"Calling GroupVersionResource with a GVK whose group/version does not exist on the cluster, when the API server is unreachable, when RBAC denies discovery access, or with an older client incompatible with the server's discovery API.","commonSituations":"Deploying to a cluster that doesn't support the resource's apiVersion (e.g. new CRDs or newer Kubernetes APIs); kubectl context pointing at the wrong cluster; cluster offline or behind a broken proxy; service account lacking discovery permissions.","solutions":["Verify cluster connectivity: kubectl cluster-info and check the current kubeconfig context","Confirm the resource's apiVersion/group exists on the cluster (kubectl api-resources | grep <resource>)","Apply the CRD or update the cluster if the API group is missing","Check RBAC: ensure the service account can call the discovery endpoints (get on the API group resources)","Upgrade the Kubernetes client libraries if the server/client discovery API versions mismatch"],"exampleFix":"// before\nres, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String())\n// after — pre-check the group version exists before mapping\nif _, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String()); err != nil {\n\treturn false, schema.GroupVersionResource{}, fmt.Errorf(\"getting server resources for group version: %w\", err)\n}","handlingStrategy":"retry","validationCode":"func checkDiscovery(disco discovery.DiscoveryInterface) error {\n\t_, err := disco.ServerResourcesForGroupVersion(\"v1\")\n\treturn err\n}","typeGuard":null,"tryCatchPattern":"ok, gvr, err := GroupVersionResource(disco, gvk)\nif err != nil {\n\tif strings.Contains(err.Error(), \"getting server resources\") {\n\t\tvar netErr net.Error\n\t\tif errors.As(err, &netErr) {\n\t\t\t// retry with backoff\n\t\t}\n\t}\n\treturn fmt.Errorf(\"cluster discovery failed, check connectivity/RBAC: %w\", err)\n}","preventionTips":["Run kubectl api-resources first to confirm the API group/version exists on the target cluster","Verify the kubeconfig context points at the intended cluster","Grant the service account discovery RBAC permissions","Add retry with backoff around discovery calls for transient network issues"],"tags":["kubernetes","discovery","network","api-server"],"backgroundTag":"api-server-discovery-failed","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}