{"record":{"id":"e9e74f1d1469b493","repo":"kubernetes/kops","slug":"unexpected-form-of-resource-path-q","errorCode":null,"errorMessage":"unexpected form of resource path: %q","messagePattern":"unexpected form of resource path: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cloudinstances/cloud_instance_group.go","lineNumber":130,"sourceCode":"\t\t}\n\t\treturn nodeMap\n\t}\n\n\tfor i := range nodes {\n\t\tnode := &nodes[i]\n\t\tproviderIDs := strings.Split(node.Spec.ProviderID, \"/\")\n\t\tinstanceID := providerIDs[len(providerIDs)-1]\n\t\tnodeMap[instanceID] = node\n\t}\n\n\treturn nodeMap\n}\n\n// toAzureVMName returns a VM name from the resource path stored in the provider ID.\nfunc toAzureVMName(providerID string) (string, error) {\n\tl := strings.Split(providerID, \"/\")\n\tif len(l) != 13 {\n\t\treturn \"\", fmt.Errorf(\"unexpected form of resource path: %q\", providerID)\n\t}\n\tvmssName := l[10]\n\tidx := l[12]\n\treturn fmt.Sprintf(\"%s_%s\", vmssName, idx), nil\n}\n","sourceCodeStart":112,"sourceCodeEnd":136,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/cloudinstances/cloud_instance_group.go#L112-L136","documentation":"toAzureVMName parses an Azure providerID of the form /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Compute/virtualMachineScaleSets/<vmss>/virtualMachines/<idx> and expects exactly 13 slash-separated segments. If the providerID does not match the VMSS resource path shape, it returns this error with the offending value.","triggerScenarios":"Calling GetNodeMap or the anonymous node-mapping helper with a node whose providerID is not a 13-segment Azure VMSS path — e.g. a standalone VM providerID, a providerID from another cloud (aws://, gce://), or an empty/malformed spec.providerID.","commonSituations":"Hybrid clusters with nodes from other providers registered in the cluster; nodes created outside VMSS (availability-set VMs); nil/unset providerID on a NotReady node; kops upgraded clusters where node registration produced a different ID format.","solutions":["Skip nodes whose providerID does not start with the Azure VMSS prefix instead of mapping them.","Verify the node's spec.providerID on the cluster and re-register misconfigured nodes.","Handle both VMSS and standalone-VM Azure providerID shapes before calling toAzureVMName."],"exampleFix":"// before\nname, err := toAzureVMName(node.Spec.ProviderID)\n// after\nif !strings.HasPrefix(node.Spec.ProviderID, \"/subscriptions/\") || !strings.Contains(node.Spec.ProviderID, \"virtualMachineScaleSets/\") {\n  continue // not an Azure VMSS instance\n}\nname, err := toAzureVMName(node.Spec.ProviderID)","handlingStrategy":"validation","validationCode":"func isAzureVMSSProviderID(id string) bool {\n  return strings.HasPrefix(id, \"/subscriptions/\") && strings.Contains(id, \"virtualMachineScaleSets/\") && len(strings.Split(id, \"/\")) == 13\n}","typeGuard":"func isAzureVMSSNode(n *v1.Node) bool {\n  return n != nil && isAzureVMSSProviderID(n.Spec.ProviderID)\n}","tryCatchPattern":"name, err := toAzureVMName(node.Spec.ProviderID)\nif err != nil {\n  klog.V(2).Infof(\"not an Azure VMSS node (%v); skipping\", err)\n  continue\n}","preventionTips":["Only pass nodes with Azure VMSS providerIDs to Azure-specific mapping code.","Treat other-cloud providerIDs (aws://, gce://) as unmanaged and skip them.","Guard against nil/empty spec.providerID before parsing."],"tags":["azure","provider-id","parsing","cloudinstances"],"backgroundTag":"invalid-provider-id-format","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"}