{"record":{"id":"a5a6087412251998","repo":"derailed/k9s","slug":"expecting-a-containspodspec-for-q-but-got-t","errorCode":null,"errorMessage":"expecting a ContainsPodSpec for %q but got %T","messagePattern":"expecting a ContainsPodSpec for %q but got %T","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/view/image_extender.go","lineNumber":173,"sourceCode":"\t\t\tSetBackgroundColorActivated(styles.ButtonFocusBgColor.Color()).\n\t\t\tSetLabelColorActivated(styles.ButtonFocusFgColor.Color())\n\t}\n\n\treturn f, nil\n}\n\nfunc (s *ImageExtender) dismissDialog() {\n\ts.App().Content.RemovePage(imageKey)\n}\n\nfunc (s *ImageExtender) getPodSpec(path string) (*corev1.PodSpec, error) {\n\tres, err := dao.AccessorFor(s.App().factory, s.GVR())\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tresourceWPodSpec, ok := res.(dao.ContainsPodSpec)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"expecting a ContainsPodSpec for %q but got %T\", s.GVR(), res)\n\t}\n\n\treturn resourceWPodSpec.GetPodSpec(path)\n}\n\nfunc (s *ImageExtender) setImages(ctx context.Context, path string, imageSpecs dao.ImageSpecs) error {\n\tres, err := dao.AccessorFor(s.App().factory, s.GVR())\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tresourceWPodSpec, ok := res.(dao.ContainsPodSpec)\n\tif !ok {\n\t\treturn fmt.Errorf(\"expecting a scalable resource for %q\", s.GVR())\n\t}\n\n\treturn resourceWPodSpec.SetImages(ctx, path, imageSpecs)\n}","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/view/image_extender.go#L155-L191","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use the image extender only on supported workloads: deployments, statefulsets, daemonsets, jobs, cronjobs, pods, etc.","For custom CRDs with pod templates, register a custom DAO implementing dao.ContainsPodSpec (GetPodSpec/SetImages)","Use the %T in the message to identify which DAO answered, then fix the registration or plugin accordingly"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func hasPodSpec(res dao.Resource) bool {\n    _, ok := res.(dao.ContainsPodSpec)\n    return ok\n}\n\n// gate the image extender keys on it:\nif !hasPodSpec(accessor) {\n    return fmt.Errorf(\"image actions unsupported for %q\", gvr)\n}","tryCatchPattern":null,"preventionTips":["Bind image-extender key bindings only to workloads with pod templates","Register a ContainsPodSpec DAO for custom CRDs before enabling image actions","Use the %T from the message to pinpoint which accessor answered"],"tags":["kubernetes","k9s","type-assertion","images","workload","dao"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}