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

  1. Inspect the raw output of curl http://169.254.169.254/hetzner/v1/metadata/private-networks on the node
  2. Upgrade kOps/nodeup to a version compatible with the current Hetzner metadata API schema
  3. Check for a proxy/middlebox injecting non-YAML content into the response
  4. 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

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


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