kubernetes/kops · error

malformed format of image urn: %s

Error message

malformed format of image urn: %s

What it means

parseImage supports Azure images given either as a resource ID or as a URN of the form publisher:offer:sku:version. If the image string contains no ':' (treated as an ID path fallback) or splits into other than exactly 4 colon-separated parts, the model builder rejects it with this error.

Source

Thrown at pkg/model/azuremodel/vmscaleset.go:251

			DiskSizeGB:   to.Ptr(volumeSize),
			ManagedDisk: &compute.VirtualMachineScaleSetManagedDiskParameters{
				StorageAccountType: &storageAccountType,
			},
			Caching: to.Ptr(compute.CachingTypesReadWrite),
		},
	}, nil
}

func parseImage(image string) (*compute.ImageReference, error) {
	if strings.HasPrefix(image, "/subscriptions/") {
		return &compute.ImageReference{
			ID: to.Ptr(image),
		}, nil
	}

	l := strings.Split(image, ":")
	if len(l) != 4 {
		return nil, fmt.Errorf("malformed format of image urn: %s", image)
	}
	return &compute.ImageReference{
		Publisher: to.Ptr(l[0]),
		Offer:     to.Ptr(l[1]),
		SKU:       to.Ptr(l[2]),
		Version:   to.Ptr(l[3]),
	}, nil
}

View on GitHub (pinned to 4c8573c808)

Solutions

  1. Use a full URN with exactly 4 parts, e.g. `Canonical:UbuntuServer:18.04-LTS:latest`, in spec.image or --image.
  2. Alternatively use the full Azure image resource ID (contains '/'), which takes the ID code path.
  3. Get the correct URN via `az vm image list --output table`.

Example fix

// before
image: Canonical:UbuntuServer:18.04-LTS
// after
image: Canonical:UbuntuServer:18.04-LTS:latest
Defensive patterns

Strategy: validation

Validate before calling

img := ig.Spec.Image
if !strings.Contains(img, "/") {
  parts := strings.Split(img, ":")
  if len(parts) != 4 {
    return fmt.Errorf("image %q must be a resource ID or urn publisher:offer:sku:version", img)
  }
}

Prevention

When it happens

Trigger: Setting spec.image on an Azure InstanceGroup to something like "UbuntuServer" or "Canonical:UbuntuServer:18.04-LTS" (3 parts) instead of a full 4-part URN or a valid image resource ID.

Common situations: Copying image names from AWS (ami-style names); omitting the version segment; using `kops create cluster --image` with a partial URN.

Understand the failure class

Related errors


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