{"record":{"id":"0190a398fc678162","repo":"kubernetes/kops","slug":"malformed-format-of-publicipaddress-id-s-d","errorCode":null,"errorMessage":"malformed format of PublicIPAddress ID: %s, %d","messagePattern":"malformed format of PublicIPAddress ID: (.+?), (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/azure/azure_utils.go","lineNumber":166,"sourceCode":"type PublicIPAddressID struct {\n\tSubscriptionID      string\n\tResourceGroupName   string\n\tPublicIPAddressName string\n}\n\n// String returns the PublicIPAddress ID in the path format.\nfunc (s *PublicIPAddressID) String() string {\n\treturn fmt.Sprintf(\"/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Network/publicIPAddresss/%s\",\n\t\ts.SubscriptionID,\n\t\ts.ResourceGroupName,\n\t\ts.PublicIPAddressName)\n}\n\n// ParsePublicIPAddressID parses a given PublicIPAddress ID string and returns a PublicIPAddress ID.\nfunc ParsePublicIPAddressID(s string) (*PublicIPAddressID, error) {\n\tl := strings.Split(s, \"/\")\n\tif len(l) != 9 {\n\t\treturn nil, fmt.Errorf(\"malformed format of PublicIPAddress ID: %s, %d\", s, len(l))\n\t}\n\treturn &PublicIPAddressID{\n\t\tSubscriptionID:      l[2],\n\t\tResourceGroupName:   l[4],\n\t\tPublicIPAddressName: l[8],\n\t}, nil\n}\n","sourceCodeStart":148,"sourceCodeEnd":174,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/azure/azure_utils.go#L148-L174","documentation":"ParsePublicIPAddressID parses an Azure public IP resource ID of the form /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/publicIPAddresses/<pip> (9 slash-separated parts). If the split yields any other count, the ID is malformed and this error is returned with the observed count. It validates the identifier before constructing a PublicIPAddressID struct.","triggerScenarios":"Calling ParsePublicIPAddressID with a truncated ID missing the public IP name, a bare name like \"my-pip\", or an ID of a different resource type (subnet = 11 parts, NSG name segment wrong) so the segment count is not 9.","commonSituations":"Pasting a vNet/subnet ID where a public IP ID is expected; portal copy that dropped the final segment; templated specs where the PIP name variable was empty; public IP renamed or recreated so old stored IDs no longer resolve.","solutions":["Use the full ID: /subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Network/publicIPAddresses/<pip-name>.","Get the exact ID via `az network public-ip show -g <rg> -n <pip> --query id`.","Confirm strings.Split(id, \"/\") has exactly 9 elements before calling.","Check no extra \"/\" appears inside the PIP name; rename the resource if so.","Correct the spec field referencing the public IP and re-run kops update cluster."],"exampleFix":"// before\npipID = \"/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses\"\n// after\npipID = \"/subscriptions/sub/resourceGroups/rg/providers/Microsoft.Network/publicIPAddresses/api-pip\"","handlingStrategy":"validation","validationCode":"// Go: validate public IP ID shape before parsing\nfunc looksLikeAzurePublicIPID(s string) bool {\n    l := strings.Split(s, \"/\")\n    return len(l) == 9 &&\n        l[1] == \"subscriptions\" &&\n        l[3] == \"resourcegroups\" &&\n        l[7] == \"publicIPAddresses\"\n}\nif !looksLikeAzurePublicIPID(pipID) {\n    return fmt.Errorf(\"expected full public IP resource ID, got %q\", pipID)\n}","typeGuard":"func isPublicIPID(s string) bool {\n    return strings.HasPrefix(s, \"/subscriptions/\") &&\n        strings.Contains(s, \"publicIPAddresses/\") &&\n        strings.Count(s, \"/\") == 8\n}","tryCatchPattern":"parsed, err := azure.ParsePublicIPAddressID(pipID)\nif err != nil {\n    log.Printf(\"public IP ID %q malformed (%v); expected /subscriptions/.../publicIPAddresses/<name>\", pipID, err)\n    return err\n}","preventionTips":["Fetch the canonical ID with az network public-ip show --query id.","Don't place vNet/subnet IDs in public-IP fields.","Watch for empty template variables leaving the PIP name segment blank.","Avoid \"/\" in public IP resource names.","Validate IDs against the 9-segment shape in CI before applying changes."],"tags":["azure","resource-id","parsing","public-ip"],"backgroundTag":"malformed-azure-resource-id","analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}