{"record":{"id":"7f2012efbc91f791","repo":"kubernetes/kops","slug":"failed-to-convert-private-networks-to-object-w","errorCode":null,"errorMessage":"failed to convert private networks to object: %w","messagePattern":"failed to convert private networks to object: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nodeup/pkg/model/context.go","lineNumber":623,"sourceCode":"\t\tclient := hcloudmetadata.NewClient()\n\t\tprivateNetworksYaml, err := client.PrivateNetworks()\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to get private networks from hetzner cloud metadata: %w\", err)\n\t\t}\n\t\tvar privateNetworks []struct {\n\t\t\tIP           net.IP   `json:\"ip\"`\n\t\t\tAliasIPs     []net.IP `json:\"alias_ips\"`\n\t\t\tInterfaceNum int      `json:\"interface_num\"`\n\t\t\tMACAddress   string   `json:\"mac_address\"`\n\t\t\tNetworkID    int      `json:\"network_id\"`\n\t\t\tNetworkName  string   `json:\"network_name\"`\n\t\t\tNetwork      string   `json:\"network\"`\n\t\t\tSubnet       string   `json:\"subnet\"`\n\t\t\tGateway      net.IP   `json:\"gateway\"`\n\t\t}\n\t\terr = yaml.Unmarshal([]byte(privateNetworksYaml), &privateNetworks)\n\t\tif err != nil {\n\t\t\treturn \"\", fmt.Errorf(\"failed to convert private networks to object: %w\", err)\n\t\t}\n\t\tfor _, privateNetwork := range privateNetworks {\n\t\t\tif privateNetwork.InterfaceNum == 1 {\n\t\t\t\tinternalIP = privateNetwork.IP.String()\n\t\t\t}\n\t\t}\n\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"getting local IP from metadata is not supported for cloud provider: %q\", c.BootConfig.CloudProvider)\n\t}\n\n\treturn internalIP, nil\n}\n\nfunc (c *NodeupModelContext) findStaticManifest(key string) *nodeup.StaticManifest {\n\tif c == nil || c.NodeupConfig == nil {\n\t\treturn nil\n\t}","sourceCodeStart":605,"sourceCodeEnd":641,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/nodeup/pkg/model/context.go#L605-L641","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"out=$(curl -sf http://169.254.169.254/hetzner/v1/metadata/private-networks) || exit 1\necho \"$out\" | python3 -c 'import sys,yaml; networks=yaml.safe_load(sys.stdin); assert isinstance(networks, list)' || echo 'unexpected metadata payload format'","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"failed to convert private networks to object\") {\n\tlog.Printf(\"Hetzner metadata payload incompatible with this nodeup version: %v\", err)\n\t// fail fast and pin/upgrade nodeup to match the metadata API\n}","preventionTips":["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"],"tags":["hetzner","yaml","metadata-service","deserialization"],"backgroundTag":"schema-validation-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"}