kubernetes/kops · error
unknown metadata type
Error message
unknown metadata type: %q in %q
What it means
When ReadFile sees a metadata:// URL, it dispatches on u.Host to a known cloud metadata provider (gce, aws, digitalocean, openstack). If the host segment names no supported provider, the library has no metadata endpoint mapping and returns this error.
Solutions
- Use one of the supported hosts: metadata://gce/..., metadata://aws/..., metadata://digitalocean/..., metadata://openstack/...
- Check spelling/casing of the provider segment immediately after metadata://
- For unsupported clouds, query the metadata service directly via its http(s) URL instead of the metadata scheme
- If you need a new provider, extend the switch in VFSContext.ReadFile in util/pkg/vfs/context.go
Example fix
// before
vfs.Context.ReadFile("metadata://azure/instance/compute")
// after
vfs.Context.ReadFile("metadata://openstack/latest/meta-data/instance-id") // supported host Defensive patterns
Strategy: validation
Validate before calling
var supportedMetadataHosts = map[string]bool{"gce": true, "aws": true, "digitalocean": true, "openstack": true}
func validateMetadataURL(loc string) error {
u, err := url.Parse(loc)
if err != nil || u.Scheme != "metadata" {
return nil // not this error's concern
}
if !supportedMetadataHosts[u.Host] {
return fmt.Errorf("unsupported metadata host %q (supported: gce, aws, digitalocean, openstack)", u.Host)
}
return nil
} Type guard
func isKnownMetadataHost(loc string) bool {
u, err := url.Parse(loc)
return err == nil && u.Scheme == "metadata" &&
(u.Host == "gce" || u.Host == "aws" || u.Host == "digitalocean" || u.Host == "openstack")
} Try / catch
data, err := vfs.Context.ReadFile(loc)
if err != nil && strings.Contains(err.Error(), "unknown metadata type") {
return fmt.Errorf("metadata scheme supports only gce/aws/digitalocean/openstack: %w", err)
} Prevention
- Keep a whitelist constant of supported metadata hosts and check against it at config load time
- Test the metadata URL in CI before deploying cluster configs
- Query unsupported clouds' IMDS directly over http://169.254.169.254 instead
When it happens
Trigger: Calling ReadFile with metadata://<unknown-host>/... - e.g. metadata://azure/instance/compute, metadata://aliyun/meta-data/instance-id, or metadata:///instance-id (empty host, because the second slash set is missing so the path lands in Host incorrectly).
Common situations: Porting scripts written for another cloud to kOps; mistyping the provider name; forgetting that azure is not supported in the metadata scheme and using metadata://azure instead of the azure IMDS URL directly.
Related errors
- Azure storage account ID is not set; it is required to…
- Azure storage account is not set on path
- Azure storage account is required
- building path for
- building path for
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/8854eb6b8f5e0747.
Report an issue: GitHub.
Appendix: source
Thrown at util/pkg/vfs/context.go:152
switch u.Scheme {
case "metadata":
switch u.Host {
case "gce":
httpURL := "http://169.254.169.254/computeMetadata/v1/" + u.Path
httpHeaders := make(map[string]string)
httpHeaders["Metadata-Flavor"] = "Google"
return c.readHTTPLocation(httpURL, httpHeaders, opts)
case "aws":
return c.readAWSMetadata(ctx, u.Path)
case "digitalocean":
httpURL := "http://169.254.169.254/metadata/v1" + u.Path
return c.readHTTPLocation(httpURL, nil, opts)
case "openstack":
httpURL := "http://169.254.169.254/latest/meta-data/" + u.Path
return c.readHTTPLocation(httpURL, nil, opts)
default:
return nil, fmt.Errorf("unknown metadata type: %q in %q", u.Host, location)
}
case "http", "https":
return c.readHTTPLocation(location, nil, opts)
}
}
location = strings.TrimPrefix(location, "file://")
p, err := c.BuildVfsPath(location)
if err != nil {
return nil, err
}
return p.ReadFile(ctx)
}
func (c *VFSContext) BuildVfsPath(p string) (Path, error) {
// NOTE: we do not want this function to take a context.Context, we consider this a "builder".View on GitHub (pinned to 4c8573c808)