GoogleContainerTools/skaffold · error

could not fetch custom resources: %w

Error message

could not fetch custom resources: %w

What it means

getCustomResources wraps errors from m.SelectResources(selector) — selecting user-configured custom resources from the manifest list — with this message. It is a local manifest-processing failure surfaced as STATUSCHECK_CUSTOM_RESOURCE_FETCH_ERR.

Source

Thrown at pkg/skaffold/kubernetes/status/status_check.go:328

	for _, r := range uRes {
		resName := r.GroupVersionKind().String()
		if r.GetName() != "" {
			resName = fmt.Sprintf("%s, Name=%s", resName, r.GetName())
		}
		pd := diag.New([]string{ns}).
			WithLabel(label.RunIDLabel, l.Labels()[label.RunIDLabel]).
			WithValidators([]validator.Validator{validator.NewConfigConnectorValidator(client, dynClient, r.GroupVersionKind())})
		result = append(result, resource.NewResource(resName, resource.ResourceTypes.ConfigConnector, ns, deadlineDuration, tolerateFailures).WithValidator(pd))
	}

	return result, nil
}

func getCustomResources(client kubernetes.Interface, dynClient dynamic.Interface, m manifest.ManifestList, ns string, deadlineDuration time.Duration, tolerateFailures bool, selector manifest.GroupKindSelector) ([]*resource.Resource, error) {
	var result []*resource.Resource
	uRes, err := m.SelectResources(selector)
	if err != nil {
		return nil, fmt.Errorf("could not fetch custom resources: %w", err)
	}
	for _, r := range uRes {
		resName := r.GroupVersionKind().String()
		if r.GetName() != "" {
			resName = fmt.Sprintf("%s, Name=%s", resName, r.GetName())
		}
		pd := diag.New([]string{ns}).
			WithValidators([]validator.Validator{validator.NewCustomValidator(client, dynClient, r.GroupVersionKind())})
		result = append(result, resource.NewResource(resName, resource.ResourceTypes.CustomResource, ns, deadlineDuration, tolerateFailures).WithValidator(pd))
	}

	return result, nil
}

func getDeployments(ctx context.Context, client kubernetes.Interface, ns string, l *label.DefaultLabeller, deadlineDuration time.Duration, tolerateFailures bool) ([]*resource.Resource, error) {
	deps, err := client.AppsV1().Deployments(ns).List(ctx, metav1.ListOptions{
		LabelSelector: l.RunIDSelector(),
	})

View on GitHub (pinned to a1189de023)

Solutions

  1. Check the GroupKindSelector spelling in skaffold.yaml against 'kubectl api-resources'
  2. Validate all rendered manifests parse (skaffold render + dry-run client apply)
  3. Regenerate manifests from helm/kustomize to fix broken rendering output
  4. Bisect manifests to find the failing resource
  5. Fix YAML issues, then re-run deploy/status check

Example fix

// before: kind casing wrong in selector
//   { group: example.com, kind: myresource }
// after:
//   { group: example.com, kind: MyResource }
Defensive patterns

Strategy: validation

Validate before calling

for (const sel of crSelectors) {
  if (!sel.GroupKind || !sel.GroupKind.group || !sel.GroupKind.kind) {
    throw new Error('invalid GroupKindSelector: group and kind are required');
  }
}

Try / catch

try {
  await statusCheck();
} catch (err) {
  if (err.message.includes('could not fetch custom resources')) {
    // selector config or manifest issue — validate config and lint manifests
  }
  throw err;
}

Prevention

When it happens

Trigger: manifest.ManifestList.SelectResources(manifest.GroupKindSelector) errors: unparseable manifest documents or an invalid/failed selection against the configured group/kind.

Common situations: statusCheck custom-resource selector misconfigured (wrong group/kind casing); manifests with YAML syntax problems; CRD kind renamed so selection logic trips; pipeline rendering emitting invalid YAML (e.g. from helm/kustomize output).

Related errors


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