kubernetes/kops · error
failed to convert network ID %q to int: %w
Error message
failed to convert network ID %q to int: %w
What it means
When rendering a Hetzner ServerGroup task, kOps converts the ID of the referenced Hetzner network (e.Network.ID) to a 64-bit integer with strconv.ParseInt. If the network ID string is empty or non-numeric, the parse fails and this wrapped error is returned, aborting server group creation.
Source
Thrown at upup/pkg/fi/cloudup/hetznertasks/servergroup.go:220
return fmt.Errorf("failed to find ssh keys for server group %q", fi.ValueOf(e.Name))
}
if e.Network == nil {
return fmt.Errorf("failed to find network for server group %q", fi.ValueOf(e.Name))
}
userData, err := fi.ResourceAsString(e.UserData)
if err != nil {
return err
}
userDataBytes, err := fi.ResourceAsBytes(e.UserData)
if err != nil {
return err
}
userDataHash := SafeBytesHash(userDataBytes)
networkID, err := strconv.ParseInt(fi.ValueOf(e.Network.ID), 10, 64)
if err != nil {
return fmt.Errorf("failed to convert network ID %q to int: %w", fi.ValueOf(e.Network.ID), err)
}
for i := 1; i <= expectedCount-actualCount; i++ {
// Append a random/unique ID to the node name
name := fmt.Sprintf("%s-%x", fi.ValueOf(e.Name), rand.Int63())
opts := hcloud.ServerCreateOpts{
Name: name,
StartAfterCreate: new(true),
Networks: []*hcloud.Network{
{
ID: networkID,
},
},
Location: &hcloud.Location{
Name: e.Location,
},
ServerType: &hcloud.ServerType{View on GitHub (pinned to 4c8573c808)
Solutions
- Set a valid numeric Hetzner network ID in the cluster spec (network.id), obtainable from the Hetzner Cloud console or `hcloud network list`.
- Verify the network reference resolves to the ID field, not the name field, in the instance group / cluster YAML.
- Run `kops replace -f cluster.yaml` (or edit) after fixing the spec and re-run the update.
Example fix
// before (cluster.yaml) network: id: my-hetzner-network // after network: id: "4711"
Defensive patterns
Strategy: validation
Validate before calling
id := fi.ValueOf(sg.Network.ID)
if n, err := strconv.ParseInt(id, 10, 64); err != nil || n <= 0 {
return fmt.Errorf("hetzner network id must be a positive integer, got %q", id)
} Type guard
func validHetznerNetworkID(id string) bool {
n, err := strconv.ParseInt(id, 10, 64)
return err == nil && n > 0
} Try / catch
if err := renderHetzner(...); err != nil {
if strings.Contains(err.Error(), "failed to convert network ID") {
// fix cluster spec network.id and retry
}
} Prevention
- Always use the numeric Hetzner network ID from `hcloud network list`, never the network name
- Quote numeric IDs in YAML so parsers do not mangle them
- Validate cluster.spec.network.id before running kops update
When it happens
Trigger: RenderHetzner is called for a HetznerServerGroup whose Network.ID is nil/empty, or contains non-numeric text (e.g. a network name like 'my-net' instead of the numeric Hetzner network ID).
Common situations: Cluster config omits network.id, or a user pastes the Hetzner network name/label instead of its numeric ID from the Hetzner Cloud console; also happens when the network reference is resolved incorrectly during cluster spec generation.
Related errors
- parsing taints for instance group %q: %w
- failed to get private networks from hetzner cloud metadata:
- failed to convert private networks to object: %w
- failed to build manifest path. Path was empty
- invalid feature gate value %q=%q: %w
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/c5119702c0e5769b.
Report an issue: GitHub.