kubernetes/kops · error

error parsing source image URL: %v

Error message

error parsing source image URL: %v

What it means

After fetching the boot disk, kOps converts its fully-qualified SourceImage URL to a short image name using ShortenImageURL(project, d.SourceImage). This error is thrown when that URL cannot be shortened — typically the image URL comes from a different project with an unexpected format or the URL is empty/malformed.

Source

Thrown at upup/pkg/fi/cloudup/gcetasks/instance.go:128

	actual.Disks = make(map[string]*Disk)
	for i, disk := range r.Disks {
		if i == 0 {
			source := disk.Source

			// TODO: Parse source URL instead of assuming same project/zone?
			name := lastComponent(source)
			d, err := cloud.Compute().Disks().Get(cloud.Project(), *e.Zone, name)
			if err != nil {
				if gce.IsNotFound(err) {
					return nil, fmt.Errorf("disk not found %q: %v", source, err)
				}
				return nil, fmt.Errorf("error querying for disk %q: %v", source, err)
			}

			image, err := ShortenImageURL(cloud.Project(), d.SourceImage)
			if err != nil {
				return nil, fmt.Errorf("error parsing source image URL: %v", err)
			}
			actual.Image = new(image)
		} else {
			url, err := gce.ParseGoogleCloudURL(disk.Source)
			if err != nil {
				return nil, fmt.Errorf("unable to parse disk source URL: %q", disk.Source)
			}

			actual.Disks[disk.DeviceName] = &Disk{Name: &url.Name}
		}
	}

	if r.Metadata != nil {
		actual.Metadata = make(map[string]fi.Resource)
		for _, i := range r.Metadata.Items {
			actual.Metadata[i.Key] = fi.NewStringResource(fi.ValueOf(i.Value))
		}
		actual.metadataFingerprint = r.Metadata.Fingerprint

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Check the disk's SourceImage: `gcloud compute disks describe <disk> --zone=<zone> --format='value(sourceImage)'`
  2. If the image lives in another project, ensure ShortenImageURL supports its URL form, or reference the image by its full path in the spec
  3. If the disk has no source image (snapshot-created), populate kops state expectation accordingly or recreate the instance from a proper image
Defensive patterns

Strategy: validation

Validate before calling

// Validate the disk's SourceImage URL shape before relying on ShortenImageURL
func validSourceImage(url string) bool {
	if url == "" { return false }
	return strings.Contains(url, "/global/images/") // projects/<p>/global/images/<name>
}

Type guard

func isParseableImageURL(project, url string) bool {
	_, err := ShortenImageURL(project, url)
	return err == nil
}

Prevention

When it happens

Trigger: ShortenImageURL returns an error because d.SourceImage doesn't match expected 'projects/<project>/global/images/<name>' or 'https://.../projects/...' patterns — e.g. image family URLs, custom images from other projects, or empty SourceImage on a blank disk.

Common situations: Boot disk created from an image family or a shared image in another project; disk created manually without a source image (e.g. from a snapshot); GCE changing URL formats across API versions.

Related errors


AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05). Data as JSON: /api/errors/a18c34ae3d185a8c. Report an issue: GitHub.