derailed/k9s · error

expecting a ContainsPodSpec for %q but got %T

Error message

expecting a ContainsPodSpec for %q but got %T

What it means

ImageExtender.getPodSpec() fetches the DAO for the GVR and asserts it implements dao.ContainsPodSpec (GetPodSpec/SetImages — resources embedding a pod template). If the accessor is a generic DAO without pod-spec awareness, the assertion fails and the message includes both the GVR and the concrete DAO type (%T).

Source

Thrown at internal/view/image_extender.go:173

			SetBackgroundColorActivated(styles.ButtonFocusBgColor.Color()).
			SetLabelColorActivated(styles.ButtonFocusFgColor.Color())
	}

	return f, nil
}

func (s *ImageExtender) dismissDialog() {
	s.App().Content.RemovePage(imageKey)
}

func (s *ImageExtender) getPodSpec(path string) (*corev1.PodSpec, error) {
	res, err := dao.AccessorFor(s.App().factory, s.GVR())
	if err != nil {
		return nil, err
	}
	resourceWPodSpec, ok := res.(dao.ContainsPodSpec)
	if !ok {
		return nil, fmt.Errorf("expecting a ContainsPodSpec for %q but got %T", s.GVR(), res)
	}

	return resourceWPodSpec.GetPodSpec(path)
}

func (s *ImageExtender) setImages(ctx context.Context, path string, imageSpecs dao.ImageSpecs) error {
	res, err := dao.AccessorFor(s.App().factory, s.GVR())
	if err != nil {
		return err
	}

	resourceWPodSpec, ok := res.(dao.ContainsPodSpec)
	if !ok {
		return fmt.Errorf("expecting a scalable resource for %q", s.GVR())
	}

	return resourceWPodSpec.SetImages(ctx, path, imageSpecs)
}

View on GitHub (pinned to 2d3ccc6ba2)

Solutions

  1. Use the image extender only on supported workloads: deployments, statefulsets, daemonsets, jobs, cronjobs, pods, etc.
  2. For custom CRDs with pod templates, register a custom DAO implementing dao.ContainsPodSpec (GetPodSpec/SetImages)
  3. Use the %T in the message to identify which DAO answered, then fix the registration or plugin accordingly
Defensive patterns

Strategy: type-guard

Type guard

func hasPodSpec(res dao.Resource) bool {
    _, ok := res.(dao.ContainsPodSpec)
    return ok
}

// gate the image extender keys on it:
if !hasPodSpec(accessor) {
    return fmt.Errorf("image actions unsupported for %q", gvr)
}

Prevention

When it happens

Trigger: Opening the image overlay / docker-like image actions on a viewer whose DAO does not implement ContainsPodSpec — custom CRDs browsed with the generic accessor, non-workload resources, or plugins reusing ImageExtender on unsupported GVRs.

Common situations: Custom plugin views for CRDs that do have podSpecs but ship no custom DAO; pressing image keys while on a resource the extender was never bound to; k9s version skew between extender and DAO registration.

Related errors


AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15). Data as JSON: /api/errors/a5a6087412251998. Report an issue: GitHub.