kubernetes/kops · error
malformed format of loadbalancer ID
Error message
malformed format of loadbalancer ID: %s, %d
What it means
ParseLoadBalancerID parses an Azure load balancer resource ID of the form /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/loadBalancers/<lb>/... where the path must split into exactly 11 slash-separated segments. If the count differs, the ID is malformed and this error reports the observed segment count. Called by the load balancer task's Find and unit tests.
Solutions
- Provide the full load balancer resource ID as expected by kOps (11 slash-delimited segments including the name segment).
- Fetch the canonical ID with `az network lb show -g <rg> -n <lb> --query id` and use it.
- Count segments (strings.Split on "/") equals 11 before passing.
- Verify the correct ID type is placed in the load balancer field of the spec, not a subnet/NSG ID.
- Re-run kops update cluster after correcting the spec.
Example fix
// before lbID = "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers" // after lbID = "/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/loadBalancers/my-lb/frontendIPConfigurations/pip"
Defensive patterns
Strategy: validation
Validate before calling
// Go: validate load balancer ID shape before parsing
func looksLikeAzureLBID(s string) bool {
l := strings.Split(s, "/")
return len(l) == 11 &&
l[1] == "subscriptions" &&
l[3] == "resourcegroups" &&
strings.Contains(s, "loadBalancers/")
}
if !looksLikeAzureLBID(lbID) {
return fmt.Errorf("expected full load balancer resource ID, got %q", lbID)
} Type guard
func isLoadBalancerID(s string) bool {
return strings.HasPrefix(s, "/subscriptions/") &&
strings.Contains(s, "loadBalancers/") &&
strings.Count(s, "/") == 10
} Try / catch
parsed, err := azure.ParseLoadBalancerID(lbID)
if err != nil {
log.Printf("load balancer ID %q malformed (%v); check segment count is 11", lbID, err)
return err
} Prevention
- Use az network lb show --query id to obtain the canonical ID.
- Verify the expected 11-segment path form for load balancer IDs in this codebase.
- Keep load balancer names free of "/" characters.
- Don't pass subnet/NSG/PIP IDs into load balancer fields.
- Validate spec ID fields with unit tests (TestLoadBalancerIDParse pattern) in CI.
When it happens
Trigger: Calling ParseLoadBalancerID with a truncated load balancer path, a bare name, or an ID of another resource type — e.g. a 9-segment NSG-style ID or an 11-segment subnet ID with wrong resource hierarchy.
Common situations: Copy-pasting a truncated ID from CLI/portal output; passing a subnet or NSG ID into a load balancer field; load balancer name containing "/" (changes count); manual edits to cluster spec api loadBalancer configuration.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- failed to parse subnet ID
- malformed format of NetworkSecurityGroup ID
- malformed format of PublicIPAddress ID
- malformed format of subnet ID
- error parsing etcd cluster tag
AI-assisted analysis of kubernetes/kops@4c8573c808 (2026-09-05).
Data as JSON: /api/errors/8a84aa103b780364.
Report an issue: GitHub.
Appendix: source
Thrown at upup/pkg/fi/cloudup/azure/azure_utils.go:138
SubscriptionID string
ResourceGroupName string
LoadBalancerName string
}
// String returns the load balancer ID in the path format.
func (lb *LoadBalancerID) String() string {
return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/loadbalancers/%s/backendAddressPools/LoadBalancerBackEnd",
lb.SubscriptionID,
lb.ResourceGroupName,
lb.LoadBalancerName,
)
}
// ParseLoadBalancerID parses a given load balancer ID string and returns a LoadBalancerID.
func ParseLoadBalancerID(lb string) (*LoadBalancerID, error) {
l := strings.Split(lb, "/")
if len(l) != 11 {
return nil, fmt.Errorf("malformed format of loadbalancer ID: %s, %d", lb, len(l))
}
return &LoadBalancerID{
SubscriptionID: l[2],
ResourceGroupName: l[4],
LoadBalancerName: l[8],
}, nil
}
// PublicIPAddressID contains the resource ID/names required to construct a PublicIPAddress ID.
type PublicIPAddressID struct {
SubscriptionID string
ResourceGroupName string
PublicIPAddressName string
}
// String returns the PublicIPAddress ID in the path format.
func (s *PublicIPAddressID) String() string {
return fmt.Sprintf("/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresss/%s",View on GitHub (pinned to 4c8573c808)