{"record":{"id":"6853612c264f0dbd","repo":"kubernetes/kops","slug":"providerid-q-not-recognized","errorCode":null,"errorMessage":"providerID %q not recognized","messagePattern":"providerID %q not recognized","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/nodeidentity/azure/identify.go","lineNumber":156,"sourceCode":"\tif i.cacheEnabled {\n\t\terr = i.cache.Add(info)\n\t\tif err != nil {\n\t\t\tklog.Warningf(\"Failed to add node identity info to cache: %v\", err)\n\t\t}\n\t}\n\n\treturn info, nil\n}\n\n// stringKeyFunc is a string as cache key function\nfunc stringKeyFunc(obj interface{}) (string, error) {\n\tkey := obj.(*nodeidentity.Info).InstanceID\n\treturn key, nil\n}\n\nfunc getVMNameFromProviderID(providerID string) (string, error) {\n\tif !strings.HasPrefix(providerID, \"azure://\") {\n\t\treturn \"\", fmt.Errorf(\"providerID %q not recognized\", providerID)\n\t}\n\n\tres, err := arm.ParseResourceID(strings.TrimPrefix(providerID, \"azure://\"))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"error parsing providerID: %v\", err)\n\t}\n\n\tswitch res.ResourceType.String() {\n\tcase \"Microsoft.Compute/virtualMachines\":\n\t\treturn res.Name, nil\n\tcase \"Microsoft.Compute/virtualMachineScaleSets/virtualMachines\":\n\t\treturn res.Parent.Name + \"_\" + res.Name, nil\n\tdefault:\n\t\treturn \"\", fmt.Errorf(\"unsupported resource type %q for providerID %q\", res.ResourceType, providerID)\n\t}\n}\n","sourceCodeStart":138,"sourceCodeEnd":173,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/pkg/nodeidentity/azure/identify.go#L138-L173","documentation":"getVMNameFromProviderID parses the providerID after trimming \"azure://\". This guard re-checks the scheme before parsing; a providerID without the \"azure://\" prefix returns this error. It is a defensive duplicate of the check in IdentifyNode and can also fire from other direct callers.","triggerScenarios":"Calling getVMNameFromProviderID directly (or via the anonymous caller) with strings like \"gce://project/zone/instance\", \"azure:///subscriptions/...\" (double slash still fails HasPrefix? no—this fires only when prefix absent, e.g. bare resource ID \"/subscriptions/.../virtualMachines/vm\"), or empty string after stripping.","commonSituations":"Custom tooling that passes the resource ID without the scheme; providerIDs written by older or third-party controllers using a different scheme; unit tests or scripts calling the helper with raw ARM IDs.","solutions":["Prefix the ID with \"azure://\" before calling, or trim the legacy \"azure:///\" form and re-add the expected scheme.","Confirm the source of the providerID (kubectl get node) and that the Azure CCM version emits the current scheme.","If invoking from custom code, normalize: if !strings.HasPrefix(id, \"azure://\") { id = \"azure://\" + strings.TrimPrefix(id, \"azure:///\") }."],"exampleFix":"// before\nname, err := getVMNameFromProviderID(node.Spec.ProviderID)\n\n// after\npid := node.Spec.ProviderID\nif !strings.HasPrefix(pid, \"azure://\") {\n    pid = \"azure://\" + strings.TrimLeft(pid, \"/\")\n}\nname, err := getVMNameFromProviderID(pid)","handlingStrategy":"validation","validationCode":"func isAzureProviderID(id string) bool {\n    return strings.HasPrefix(id, \"azure://\")\n}\nif !isAzureProviderID(node.Spec.ProviderID) {\n    return fmt.Errorf(\"cannot parse providerID %q\", node.Spec.ProviderID)\n}","typeGuard":"func isAzureProviderID(id string) bool {\n    return strings.HasPrefix(id, \"azure://\")\n}","tryCatchPattern":"name, err := getVMNameFromProviderID(pid)\nif err != nil && strings.Contains(err.Error(), \"not recognized\") {\n    return fmt.Errorf(\"normalize providerID %q to azure:// scheme first\", pid)\n}","preventionTips":["Normalize providerIDs to the azure:// scheme before calling helpers","Unit-test helpers with providerIDs from all clouds you support","Log the raw providerID whenever parsing fails to spot scheme drift"],"tags":["azure","provider-id","parsing","kops"],"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"}