{"record":{"id":"e13a306bf8ff9bed","repo":"kubernetes/kops","slug":"error-parsing-selector-v-w","errorCode":null,"errorMessage":"error parsing selector %v: %w","messagePattern":"error parsing selector (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/bootstrapchannelbuilder/pruning.go","lineNumber":43,"sourceCode":"\t\"k8s.io/apimachinery/pkg/util/sets\"\n\t\"k8s.io/klog/v2\"\n\n\tchannelsapi \"k8s.io/kops/channels/pkg/api\"\n\t\"k8s.io/kops/pkg/kubemanifest\"\n\t\"k8s.io/kops/pkg/model/components/addonmanifests\"\n)\n\nfunc buildPruneDirectives(spec *channelsapi.AddonSpec, manifestData []byte) error {\n\tspec.Prune = &channelsapi.PruneSpec{}\n\n\t// We add these labels to all objects we manage, so we reuse them for pruning.\n\tselectorMap := map[string]string{\n\t\t\"app.kubernetes.io/managed-by\":   \"kops\",\n\t\taddonmanifests.KopsAddonLabelKey: *spec.Name,\n\t}\n\tselector, err := labels.ValidatedSelectorFromSet(selectorMap)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing selector %v: %w\", selectorMap, err)\n\t}\n\n\t// We always include a set of well-known group kinds,\n\t// so that we prune even if we end up removing something from the manifest.\n\talwaysPruneGroupKinds := []schema.GroupKind{\n\t\t{Group: \"\", Kind: \"ConfigMap\"},\n\t\t{Group: \"\", Kind: \"Service\"},\n\t\t{Group: \"\", Kind: \"ServiceAccount\"},\n\t\t{Group: \"admissionregistration.k8s.io\", Kind: \"MutatingWebhookConfiguration\"},\n\t\t{Group: \"admissionregistration.k8s.io\", Kind: \"ValidatingWebhookConfiguration\"},\n\t\t{Group: \"apps\", Kind: \"Deployment\"},\n\t\t{Group: \"apps\", Kind: \"DaemonSet\"},\n\t\t{Group: \"apps\", Kind: \"StatefulSet\"},\n\t\t{Group: \"rbac.authorization.k8s.io\", Kind: \"ClusterRole\"},\n\t\t{Group: \"rbac.authorization.k8s.io\", Kind: \"ClusterRoleBinding\"},\n\t\t{Group: \"rbac.authorization.k8s.io\", Kind: \"Role\"},\n\t\t{Group: \"rbac.authorization.k8s.io\", Kind: \"RoleBinding\"},\n\t\t{Group: \"policy\", Kind: \"PodDisruptionBudget\"},","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/bootstrapchannelbuilder/pruning.go#L25-L61","documentation":"buildPruneDirectives constructs a fixed label selector (managed-by=kops plus the addon name) used for pruning old addon objects. The selector is validated with labels.ValidatedSelectorFromSet; if invalid, this error is returned with the offending map.","triggerScenarios":"An addon spec with an empty or nil Name pointer (making *spec.Name invalid in the selector set) while Normalizing an AddonManifest and computing prune directives.","commonSituations":"Addon manifests missing the required 'name' field; programmatically built addon specs that omit Name; channel files corrupted or truncated.","solutions":["Set the addon name in the manifest: spec.Name must be a non-empty valid label value","Validate the addon manifest name field before building","Fix the channel YAML so the addon has a proper name","Use kops toolkit tools to verify addon manifest schema"],"exampleFix":"// before (addon manifest)\nspec:\n  # name missing\n  version: 1.0.0\n// after\nspec:\n  name: my-addon\n  version: 1.0.0","handlingStrategy":"validation","validationCode":"// Verify addon name is a valid label value before Normalize\nif spec.Name == nil || *spec.Name == \"\" {\n    return errors.New(\"addon spec.name required for prune directives\")\n}\nif errs := validation.IsValidLabelValue(*spec.Name); len(errs) > 0 {\n    return fmt.Errorf(\"invalid addon name %q: %v\", *spec.Name, errs)\n}","typeGuard":null,"tryCatchPattern":"selector, err := labels.ValidatedSelectorFromSet(selectorMap)\nif err != nil {\n    return fmt.Errorf(\"addon manifest name invalid; set spec.name: %w\", err)\n}","preventionTips":["Always set spec.name in addon manifests","Validate channel manifests against the kops addon schema","Never hand-strip required fields from channel YAML"],"tags":["selector","labels","addons","kops"],"backgroundTag":"invalid-label-selector","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}