{"record":{"id":"cf1bdf750376d636","repo":"kubernetes/kops","slug":"error-parsing-source-image-url-v-cf1bdf","errorCode":null,"errorMessage":"error parsing source image URL: %v","messagePattern":"error parsing source image URL: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/gcetasks/instancetemplate.go","lineNumber":133,"sourceCode":"\t\t\tcontinue\n\t\t}\n\n\t\tif !matches(expected, r) {\n\t\t\tcontinue\n\t\t}\n\n\t\tactual := &InstanceTemplate{}\n\n\t\tp := r.Properties\n\n\t\tactual.Tags = append(actual.Tags, p.Tags.Items...)\n\t\tactual.Labels = p.Labels\n\t\tactual.MachineType = new(lastComponent(p.MachineType))\n\t\tactual.CanIPForward = &p.CanIpForward\n\n\t\tbootDiskImage, err := ShortenImageURL(cloud.Project(), p.Disks[0].InitializeParams.SourceImage)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"error parsing source image URL: %v\", err)\n\t\t}\n\t\tactual.BootDiskImage = new(bootDiskImage)\n\t\tactual.BootDiskType = &p.Disks[0].InitializeParams.DiskType\n\t\tactual.BootDiskSizeGB = &p.Disks[0].InitializeParams.DiskSizeGb\n\t\tif p.Disks[0].InitializeParams.ProvisionedIops > 0 {\n\t\t\tactual.BootDiskIOPS = &p.Disks[0].InitializeParams.ProvisionedIops\n\t\t}\n\t\tif p.Disks[0].InitializeParams.ProvisionedThroughput > 0 {\n\t\t\tactual.BootDiskThroughput = &p.Disks[0].InitializeParams.ProvisionedThroughput\n\t\t}\n\n\t\tif p.Scheduling != nil {\n\t\t\tactual.Preemptible = &p.Scheduling.Preemptible\n\t\t\tactual.GCPProvisioningModel = &p.Scheduling.ProvisioningModel\n\t\t}\n\t\tif len(p.NetworkInterfaces) != 0 {\n\t\t\tni := p.NetworkInterfaces[0]\n\t\t\tactual.Network = &Network{Name: new(lastComponent(ni.Network))}","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/gcetasks/instancetemplate.go#L115-L151","documentation":"While reconstructing the actual state of a matching GCE instance template, Find calls ShortenImageURL to convert the template's boot disk SourceImage URL back into the short 'project/image' form used in the kOps spec. If the URL cannot be parsed (or the image can't be attributed to a project), the error is wrapped and returned.","triggerScenarios":"An instance template whose boot disk SourceImage doesn't match the expected https://www.googleapis.com/compute/v1/projects/<proj>/global/images/<name> format — e.g. the template was created out-of-band using an image family URL, a deprecated/custom image reference, or an empty/odd SourceImage value.","commonSituations":"Manual template creation via gcloud with `--image-family` or a shortened image name; images created in a different project; templates built by other tooling that kOps' Find loop then encounters while prefix-matching.","solutions":["Inspect the wrapped inner error to see the offending SourceImage URL","Identify which instance template (matching the NamePrefix) has the malformed SourceImage","Fix the template's SourceImage to a fully-qualified project-global image URL (e.g. via gcloud compute instance-templates or recreating it with kOps)","If the template was created out-of-band and is unwanted, delete it so Find no longer matches it","Upgrade kOps — newer versions may parse more URL forms"],"exampleFix":"// before (out-of-band template)\ngcloud compute instance-templates create mytpl --image-family ubuntu-2004-lts --image-project ubuntu-os-cloud\n// after\n# use a fully-qualified source image, or let kOps create/replace the template:\ngcloud compute instances ... --image https://www.googleapis.com/compute/v1/projects/ubuntu-os-cloud/global/images/ubuntu-2004-focal-v20240307b\n# or delete the stray template: gcloud compute instance-templates delete mytpl","handlingStrategy":"validation","validationCode":"# Ensure any instance template matching your kOps NamePrefix uses a fully-qualified image URL:\ngcloud compute instance-templates list --format=\"value(name)\" | grep '^<nameprefix>-' | \\\n  xargs -I{} sh -c 'gcloud compute instance-templates describe {} --format=\"value(properties.disks[0].initializeParams.sourceImage)\" | grep -q \"compute/v1/projects/.*/global/images/\" || echo \"BAD image URL on {}\"'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always create templates with fully-qualified source image URLs, not families or short names","Let kOps manage all instance templates whose names share your NamePrefix","Clean up out-of-band templates (or name them differently) so Find never matches them","Pin BootDiskImage in the kOps spec to 'project/image' form kOps expects"],"tags":["gce","instance-template","image-url","parsing"],"backgroundTag":"image-url-parse-failed","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"}