GoogleContainerTools/skaffold · error

getting group version resource from obj: %w

Error message

getting group version resource from obj: %w

What it means

updateRuntimeObject resolves the GroupVersionResource from the object's GroupVersionKind using the discovery API (util.GroupVersionResource performs a RESTMapping lookup). This error means discovery could not map the GVK to a resource — the API server does not serve that kind, or discovery itself failed.

Source

Thrown at pkg/skaffold/deploy/label/labels.go:103

}

func updateRuntimeObject(ctx context.Context, client dynamic.Interface, disco discovery.DiscoveryInterface, labels map[string]string, res deploy.Artifact, kubeContext string) error {
	originalJSON, _ := json.Marshal(res.Obj)
	modifiedObj := res.Obj.DeepCopyObject()
	accessor, err := meta.Accessor(modifiedObj)
	if err != nil {
		return fmt.Errorf("getting metadata accessor: %w", err)
	}
	name := accessor.GetName()

	addLabels(labels, accessor)

	modifiedJSON, _ := json.Marshal(modifiedObj)
	p, _ := patch.CreateTwoWayMergePatch(originalJSON, modifiedJSON, modifiedObj)

	namespaced, gvr, err := util.GroupVersionResource(disco, modifiedObj.GetObjectKind().GroupVersionKind())
	if err != nil {
		return fmt.Errorf("getting group version resource from obj: %w", err)
	}

	if namespaced {
		var namespace string
		if accessor.GetNamespace() != "" {
			namespace = accessor.GetNamespace()
		} else {
			namespace = res.Namespace
		}

		ns, err := resolveNamespace(namespace, kubeContext)
		if err != nil {
			return fmt.Errorf("resolving namespace: %w", err)
		}

		log.Entry(ctx).Debug("Patching", name, "in namespace", ns)
		if _, err := client.Resource(gvr).Namespace(ns).Patch(ctx, name, types.StrategicMergePatchType, p, metav1.PatchOptions{}); err != nil {
			return fmt.Errorf("patching resource %s/%q: %w", ns, name, err)

View on GitHub (pinned to a1189de023)

Solutions

  1. Install the CRD for the custom kind before deploying: `kubectl apply -f crd.yaml`
  2. Fix the apiVersion/kind in the manifest to match a resource served by the cluster (`kubectl api-resources | grep <kind>`)
  3. Verify cluster connectivity with `kubectl version` — discovery requires a reachable API server
  4. Run `kubectl explain <resource>` to confirm the correct group/version

Example fix

// before
apiVersion: extensions/v1beta1
kind: Deployment
// after
apiVersion: apps/v1
kind: Deployment
Defensive patterns

Strategy: validation

Validate before calling

// verify the GVK is served before deploying
res, err := disco.ServerResourcesForGroupVersion(gvk.GroupVersion().String())
if err != nil || !containsKind(res.APIResources, gvk.Kind) {
    return fmt.Errorf("kind %s not served in %s — install CRDs first", gvk.Kind, gvk.GroupVersion())
}

Try / catch

_, gvr, err := util.GroupVersionResource(disco, gvk)
if err != nil {
    return fmt.Errorf("no RESTMapping for %s — is its CRD installed? %w", gvk, err)
}

Prevention

When it happens

Trigger: Patching an object whose GVK is not registered on the target cluster (missing CRD); the discovery client cannot reach the API server; an unsupported/typo'd apiVersion in the manifest.

Common situations: Deploying CRs before their CRDs are installed; wrong apiVersion string after a Kubernetes API migration (e.g. extensions/v1beta1 to apps/v1); cluster unreachable so discovery returns no resources.

Related errors


AI-assisted analysis of GoogleContainerTools/skaffold@a1189de023 (2026-09-05). Data as JSON: /api/errors/084bfcdc9184e9b6. Report an issue: GitHub.