{"record":{"id":"df79182a01dcc730","repo":"derailed/k9s","slug":"unsupported-resource-for-scaling-s","errorCode":null,"errorMessage":"unsupported resource for scaling: %s","messagePattern":"unsupported resource for scaling: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/dao/dp.go","lineNumber":394,"sourceCode":"\tswitch gvr {\n\tcase client.DpGVR:\n\t\tscale, e := dial.AppsV1().Deployments(ns).GetScale(ctx, n, metav1.GetOptions{})\n\t\tif e != nil {\n\t\t\treturn e\n\t\t}\n\t\tscale.Spec.Replicas = replicas\n\t\t_, e = dial.AppsV1().Deployments(ns).UpdateScale(ctx, n, scale, metav1.UpdateOptions{})\n\t\treturn e\n\tcase client.StsGVR:\n\t\tscale, e := dial.AppsV1().StatefulSets(ns).GetScale(ctx, n, metav1.GetOptions{})\n\t\tif e != nil {\n\t\t\treturn e\n\t\t}\n\t\tscale.Spec.Replicas = replicas\n\t\t_, e = dial.AppsV1().StatefulSets(ns).UpdateScale(ctx, n, scale, metav1.UpdateOptions{})\n\t\treturn e\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported resource for scaling: %s\", gvr)\n\t}\n}\n\nfunc restartRes[T runtime.Object](ctx context.Context, f Factory, gvr *client.GVR, path string, opts *metav1.PatchOptions) error {\n\to, err := f.Get(gvr, path, true, labels.Everything())\n\tif err != nil {\n\t\treturn err\n\t}\n\tvar r = new(T)\n\terr = runtime.DefaultUnstructuredConverter.FromUnstructured(o.(*unstructured.Unstructured).Object, r)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tns, n := client.Namespaced(path)\n\tauth, err := f.Client().CanI(ns, gvr, n, client.PatchAccess)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":376,"sourceCodeEnd":412,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/dao/dp.go#L376-L412","documentation":"scaleRes (internal/dao/dp.go:394-396) supports exactly two GVRs - client.DpGVR (Deployments) and client.StsGVR (StatefulSets). Any other GVR that reaches this generic helper falls through the switch's default and is rejected with this message printing the GVR.","triggerScenarios":"Routing a scale request for an unsupported kind through scaleRes - e.g. a Replicaset, ReplicationController, or a custom CRD with a scale subresource. Authorization (error 113) is checked before this switch, so you only see this error after RBAC passed.","commonSituations":"Extending k9s DAOs or writing plugins that call the scale path for other controllers; version drift where a caller assumed a GVR was added to the supported set.","solutions":["Scale only Deployments or StatefulSets through this path","For other scalable kinds, use the resource-specific client (e.g. dial.AppsV1().ReplicaSets(ns).UpdateScale) or kubectl scale","If you control the code, add a case for the GVR before the default branch"],"exampleFix":"// before\nscaleRes(ctx, f, client.RsGVR, path, 3) // falls into default\n// after\ncase client.RsGVR:\n    scale, e := dial.AppsV1().ReplicaSets(ns).GetScale(ctx, n, metav1.GetOptions{})\n    if e != nil { return e }\n    scale.Spec.Replicas = replicas\n    _, e = dial.AppsV1().ReplicaSets(ns).UpdateScale(ctx, n, scale, metav1.UpdateOptions{})\n    return e","handlingStrategy":"type-guard","validationCode":"// Reject unsupported GVRs before any authorization or API traffic.\nfunc Scalable(gvr *client.GVR) bool {\n\treturn gvr == client.DpGVR || gvr == client.StsGVR\n}","typeGuard":"func ScaleTarget(gvr *client.GVR) (apply func(ctx context.Context, ns, name string, replicas int32) error, err error) {\n    switch gvr {\n    case client.DpGVR:\n        return applyDpScale, nil\n    case client.StsGVR:\n        return applyStsScale, nil\n    default:\n        return nil, fmt.Errorf(\"unsupported resource for scaling: %s\", gvr)\n    }\n}","tryCatchPattern":"if !Scalable(gvr) { return fmt.Errorf(\"unsupported resource for scaling: %s\", gvr) }\nreturn scaleRes(ctx, f, gvr, path, replicas)","preventionTips":["Type-guard at the call site: never route ReplicaSets/CRDs into the shared scale helper","When adding a scalable kind, extend the switch AND the RBAC pre-check list together"],"tags":["go","kubernetes","k9s","scale","gvr","unsupported"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}