{"record":{"id":"7b85fd5247654f7c","repo":"kubernetes/kops","slug":"image-is-required","errorCode":null,"errorMessage":"image is required","messagePattern":"image is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/template_functions_karpenter.go","lineNumber":459,"sourceCode":"\t}\n\tif ig.Spec.MaxSize != nil {\n\t\tspec.Limits = &karpenterNodePoolLimits{Nodes: strconv.FormatInt(int64(*ig.Spec.MaxSize), 10)}\n\t}\n\n\treturn &karpenterNodePool{\n\t\tAPIVersion: karpenterNodePoolAPIGroup + \"/v1\",\n\t\tKind:       \"NodePool\",\n\t\tMetadata: karpenterObjectMeta{\n\t\t\tName: ig.Name,\n\t\t},\n\t\tSpec: spec,\n\t}, nil\n}\n\nfunc buildKarpenterAMITerms(image string) ([]karpenterAMITerm, error) {\n\timage = strings.TrimSpace(image)\n\tif image == \"\" {\n\t\treturn nil, fmt.Errorf(\"image is required\")\n\t}\n\tif strings.Contains(image, \"://\") {\n\t\treturn nil, fmt.Errorf(\"image %q must be ami-*, ssm:<parameter>, <name>, or <owner>/<name>\", image)\n\t}\n\tif strings.HasPrefix(image, \"ami-\") {\n\t\treturn []karpenterAMITerm{{ID: image}}, nil\n\t}\n\tif strings.HasPrefix(image, \"ssm:\") {\n\t\tparameter := strings.TrimPrefix(image, \"ssm:\")\n\t\tif parameter == \"\" {\n\t\t\treturn nil, fmt.Errorf(\"ssm image parameter is required\")\n\t\t}\n\t\treturn []karpenterAMITerm{{SSMParameter: parameter}}, nil\n\t}\n\n\ttokens := strings.SplitN(image, \"/\", 2)\n\tif len(tokens) == 1 {\n\t\treturn []karpenterAMITerm{{Name: image, Owner: \"self\"}}, nil","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/template_functions_karpenter.go#L441-L477","documentation":"buildKarpenterAMITerms converts the configured image spec into Karpenter EC2NodeClass AMI terms. An empty/whitespace-only image string is rejected with 'image is required', since no AMI selector can be produced without an image.","triggerScenarios":"Calling buildKarpenterEC2NodeClass (or using the template function in a template) with the image field empty after strings.TrimSpace — e.g. image set to \"\" or only spaces in the instance group/config.","commonSituations":"Omitting the image field in a Karpenter instance group spec; a config templating step leaving the placeholder blank; yaml key present but value empty after env-substitution failed.","solutions":["Set the image field in the instance group spec to an ami-*, ssm:<parameter>, <name>, or <owner>/<name> value","If using env substitution in your config, verify the variable actually resolves","Re-run `kops update cluster` after setting the image"],"exampleFix":"// before\nimage: \"\"\n// after\nimage: ami-0abcdef1234567890","handlingStrategy":"validation","validationCode":"// ensure image is set before rendering\nif strings.TrimSpace(ig.Spec.Image) == \"\" {\n\treturn fmt.Errorf(\"instance group %s: image must be set\", ig.Name)\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"image is required\") {\n\treturn fmt.Errorf(\"set image field for the karpenter instance group\")\n}","preventionTips":["Always populate image in Karpenter instance group specs","Check env-substitution pipelines resolve image placeholders","Run a kops dry-run to catch missing fields before apply"],"tags":["karpenter","aws","validation","missing-value"],"backgroundTag":"missing-required-argument","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"}