{"record":{"id":"9443da13cf6dba33","repo":"kubernetes/kops","slug":"building-amiselectorterms-for-q-w","errorCode":null,"errorMessage":"building amiSelectorTerms for %q: %w","messagePattern":"building amiSelectorTerms for %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":217,"sourceCode":"\tnodePool, err := tf.buildKarpenterNodePool(ig)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\treturn marshalKarpenterResource(ig, nodePool)\n}\n\nfunc marshalKarpenterResource(ig *kops.InstanceGroup, object interface{}) (string, error) {\n\tdata, err := yaml.Marshal(object)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"marshaling Karpenter resource for %q: %w\", ig.Name, err)\n\t}\n\treturn strings.TrimSpace(string(data)), nil\n}\n\nfunc (tf *TemplateFunctions) buildKarpenterEC2NodeClass(ig *kops.InstanceGroup) (*karpenterEC2NodeClass, error) {\n\tamiSelectorTerms, err := buildKarpenterAMITerms(ig.Spec.Image)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building amiSelectorTerms for %q: %w\", ig.Name, err)\n\t}\n\n\tinstanceProfile, err := tf.LinkToIAMInstanceProfile(ig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building instance profile for %q: %w\", ig.Name, err)\n\t}\n\n\ttags, err := tf.CloudTagsForInstanceGroup(ig)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"building tags for %q: %w\", ig.Name, err)\n\t}\n\ttags = karpenterEC2NodeClassTags(tags)\n\tassociatePublicIP, err := tf.karpenterAssociatePublicIP(ig)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tuserData, err := tf.managedFileContents(\"nodeupscript-\" + ig.Name)\n\tif err != nil {","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L199-L235","documentation":"Returned by buildKarpenterEC2NodeClass when buildKarpenterAMITerms(ig.Spec.Image) fails to translate the instance group's image setting into valid Karpenter amiSelectorTerms. The error names the instance group so the broken image spec can be located.","triggerScenarios":"ig.Spec.Image is set to a value buildKarpenterAMITerms cannot parse — an unrecognized alias, an invalid AMI selector expression, or an empty/invalid image string where a concrete selector is required.","commonSituations":"Instance group image set to an unsupported alias (e.g. a distro name not handled), typo in a selector string, image field left at an older format after upgrading kops, cross-account/private AMI IDs unsupported.","solutions":["Check ig.Spec.Image for the named instance group and correct the image value","Use a supported image alias or a full AMI ID / valid selector term","Compare with buildKarpenterAMITerms implementation for accepted formats","Run kops cluster spec validation before rendering"],"exampleFix":"// before\nimage: my-custom-thing\n// after\nimage: 099720109477/ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-20240215  # or a supported alias","handlingStrategy":"validation","validationCode":"// pre-validate the image before rendering Karpenter resources\nif ig.Spec.Image == \"\" || !isValidKarpenterImageSelector(ig.Spec.Image) {\n\treturn fmt.Errorf(\"instance group %q has unsupported image %q\", ig.Name, ig.Spec.Image)\n}","typeGuard":null,"tryCatchPattern":"nc, err := tf.KarpenterEC2NodeClass(ig)\nif err != nil {\n\treturn fmt.Errorf(\"EC2NodeClass for %q: %w\", ig.Name, err)\n}","preventionTips":["Validate ig.Spec.Image against supported aliases/selectors before cluster creation","Use kops-supported image identifiers (aliases or known AMI IDs)","Add spec validation tests for image values on Karpenter instance groups","Re-validate specs after kops upgrades where image handling changes"],"tags":["karpenter","ami","instance-group","kops"],"backgroundTag":"invalid-ami-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"}