kubernetes/kops · error
failed to convert private networks to object: %w
Error message
failed to convert private networks to object: %w
What it means
After fetching the private-networks YAML from the Hetzner metadata service, nodeup unmarshals it into a typed slice. If the payload is not valid YAML or does not match the expected structure (ip, alias_ips, interface_num, etc.), the yaml.Unmarshal error is wrapped with this message.
Source
Thrown at nodeup/pkg/model/context.go:623
client := hcloudmetadata.NewClient()
privateNetworksYaml, err := client.PrivateNetworks()
if err != nil {
return "", fmt.Errorf("failed to get private networks from hetzner cloud metadata: %w", err)
}
var privateNetworks []struct {
IP net.IP `json:"ip"`
AliasIPs []net.IP `json:"alias_ips"`
InterfaceNum int `json:"interface_num"`
MACAddress string `json:"mac_address"`
NetworkID int `json:"network_id"`
NetworkName string `json:"network_name"`
Network string `json:"network"`
Subnet string `json:"subnet"`
Gateway net.IP `json:"gateway"`
}
err = yaml.Unmarshal([]byte(privateNetworksYaml), &privateNetworks)
if err != nil {
return "", fmt.Errorf("failed to convert private networks to object: %w", err)
}
for _, privateNetwork := range privateNetworks {
if privateNetwork.InterfaceNum == 1 {
internalIP = privateNetwork.IP.String()
}
}
default:
return "", fmt.Errorf("getting local IP from metadata is not supported for cloud provider: %q", c.BootConfig.CloudProvider)
}
return internalIP, nil
}
func (c *NodeupModelContext) findStaticManifest(key string) *nodeup.StaticManifest {
if c == nil || c.NodeupConfig == nil {
return nil
}View on GitHub (pinned to 4c8573c808)
Solutions
- Inspect the raw output of curl http://169.254.169.254/hetzner/v1/metadata/private-networks on the node
- Upgrade kOps/nodeup to a version compatible with the current Hetzner metadata API schema
- Check for a proxy/middlebox injecting non-YAML content into the response
- Report upstream to kOps if the metadata service schema changed and nodeup needs a struct update
Example fix
null
Defensive patterns
Strategy: validation
Validate before calling
out=$(curl -sf http://169.254.169.254/hetzner/v1/metadata/private-networks) || exit 1 echo "$out" | python3 -c 'import sys,yaml; networks=yaml.safe_load(sys.stdin); assert isinstance(networks, list)' || echo 'unexpected metadata payload format'
Try / catch
if err != nil && strings.Contains(err.Error(), "failed to convert private networks to object") {
log.Printf("Hetzner metadata payload incompatible with this nodeup version: %v", err)
// fail fast and pin/upgrade nodeup to match the metadata API
} Prevention
- Keep nodeup and kOps versions in sync with the Hetzner metadata API you run against
- Validate the raw metadata payload format when debugging bootstrap failures
- Ensure no proxy or middlebox rewrites the metadata response body
- Pin kOps versions when automating cluster provisioning to avoid schema drift
When it happens
Trigger: client.PrivateNetworks() returns a payload that yaml.Unmarshal cannot decode into []struct{IP net.IP; ...} — malformed YAML, empty/garbage body, or an incompatible metadata API response format.
Common situations: Hetzner metadata API changed its response schema (kOps/nodeup version mismatch with a newer metadata service); proxy or middlebox returning an HTML error page instead of YAML; corrupted/empty response when the server has no private networks.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- error parsing %v: %w
- failed to get private networks from hetzner cloud metadata:
- error unmarshaling subobject %s: %v
- error parsing addons or manifest: %v
- error parsing addons: %v
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/7f2012efbc91f791.
Report an issue: GitHub.