{"record":{"id":"ba0be0ae77d7abd8","repo":"GoogleContainerTools/skaffold","slug":"listing-resources-of-kind-v-w","errorCode":null,"errorMessage":"listing resources of kind %v: %w","messagePattern":"listing resources of kind (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/diag/validator/custom_resource.go","lineNumber":74,"sourceCode":"\t\trs = append(rs, NewResourceFromObject(&r, Status(status), ae, nil))\n\t}\n\treturn rs, nil\n}\n\n// NewCustomValidator initializes a CustomValidator\nfunc NewCustomValidator(k kubernetes.Interface, d dynamic.Interface, gvk schema.GroupVersionKind) *CustomValidator {\n\treturn &CustomValidator{resourceSelector: NewCustomResourceSelector(k, d, gvk)}\n}\n\nfunc NewCustomResourceSelector(client kubernetes.Interface, dynClient dynamic.Interface, gvk schema.GroupVersionKind) *CustomResourceSelector {\n\treturn &CustomResourceSelector{client: client, dynClient: dynClient, kind: gvk}\n}\n\n// Select returns the updated list of custom resources for the given GroupVersionKind deployed by skaffold\nfunc (c *CustomResourceSelector) Select(ctx context.Context, namespace string, opts metav1.ListOptions) (*unstructured.UnstructuredList, error) {\n\t_, r, err := util.GroupVersionResource(c.client.Discovery(), c.kind)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"listing resources of kind %v: %w\", c.kind, err)\n\t}\n\tresList, err := c.dynClient.Resource(r).Namespace(namespace).List(ctx, opts)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"listing resources of kind %v: %w\", c.kind, err)\n\t}\n\treturn resList, nil\n}\n\nfunc getResourceStatus(res unstructured.Unstructured) (kstatus.Status, *proto.ActionableErr) {\n\tresult, err := kstatus.Compute(&res)\n\tif err != nil || result == nil {\n\t\treturn kstatus.UnknownStatus, &proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_UNKNOWN, Message: \"unable to check resource status\"}\n\t}\n\tvar ae proto.ActionableErr\n\tswitch result.Status {\n\tcase kstatus.CurrentStatus:\n\t\tae = proto.ActionableErr{ErrCode: proto.StatusCode_STATUSCHECK_SUCCESS}\n\tcase kstatus.InProgressStatus:","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/diag/validator/custom_resource.go#L56-L92","documentation":"CustomResourceSelector.Select resolves the GroupVersionResource for the configured custom resource kind via discovery. If discovery lookup of the kind fails (kind not registered on the cluster/API server), the error is wrapped as `listing resources of kind <kind>: ...`. It means skaffold cannot map the kind to a REST resource before even listing.","triggerScenarios":"Calling Select (via Validate/diagnose) for a CRD kind that is not installed in the target cluster — discovery returns no match for util.GroupVersionResource; also fires on discovery API connectivity errors.","commonSituations":"Diagnosing a cluster where the CRD (e.g. some custom workload kind) hasn't been applied yet; wrong apiGroup/kind spelling in config; connecting skaffold to the wrong kubeconfig context.","solutions":["Apply the CRD to the cluster: `kubectl apply -f <crd.yaml>` and verify with `kubectl api-resources | grep <kind>`.","Fix the kind/apiGroup name in your skaffold config to match the installed CRD exactly.","Confirm you are pointed at the intended cluster (`kubectl config current-context`)."],"exampleFix":"// before (kind not installed)\nskaffold diagnose  # listing resources of kind MyKind: the server could not find...\n// after\nkubectl apply -f crds/mykind-crd.yaml && skaffold diagnose","handlingStrategy":"validation","validationCode":"out, _ := exec.Command(\"kubectl\", \"api-resources\").Output()\nif !strings.Contains(string(out), kind) {\n    return fmt.Errorf(\"kind %s not installed in cluster; apply its CRD first\", kind)\n}","typeGuard":null,"tryCatchPattern":"if err := selector.Select(ctx, ns, opts); err != nil {\n    if strings.Contains(err.Error(), \"listing resources of kind\") {\n        // verify CRD is applied / kind spelling\n    }\n}","preventionTips":["Apply all CRDs as a prerequisite step before running skaffold diagnose.","Verify kind names with `kubectl api-resources`.","Confirm the correct kubeconfig context is active."],"tags":["kubernetes","crd","discovery","skaffold"],"backgroundTag":"resource-not-found","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"}