{"record":{"id":"41ab736f5b09e529","repo":"kubernetes/kops","slug":"fixed-ip-was-not-a-string-v","errorCode":null,"errorMessage":"Fixed IP was not a string: %v","messagePattern":"Fixed IP was not a string: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/utils.go","lineNumber":116,"sourceCode":"\t\treturn \"\", fmt.Errorf(\"unhandled role %q\", ig.Spec.Role)\n\t}\n\tif len(candidates) == 0 {\n\t\treturn \"\", fmt.Errorf(\"No suitable flavor for role %q\", ig.Spec.Role)\n\t}\n\treturn candidates[0].Name, nil\n}\n\nfunc GetServerFixedIP(server *servers.Server, interfaceName string) (poolAddress string, err error) {\n\tif localAddr, ok := server.Addresses[interfaceName]; ok {\n\t\tif localAddresses, ok := localAddr.([]interface{}); ok {\n\t\t\tfor _, addr := range localAddresses {\n\t\t\t\taddrMap := addr.(map[string]interface{})\n\t\t\t\tif addrType, ok := addrMap[openstackExternalIPType]; ok && addrType == openstackAddressFixed {\n\t\t\t\t\tif fixedIP, ok := addrMap[openstackAddress]; ok {\n\t\t\t\t\t\tif fixedIPStr, ok := fixedIP.(string); ok {\n\t\t\t\t\t\t\tpoolAddress = fixedIPStr\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\terr = fmt.Errorf(\"Fixed IP was not a string: %v\", fixedIP)\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\terr = fmt.Errorf(\"Type fixed did not contain addr: %v\", addr)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t} else {\n\t\terr = fmt.Errorf(\"server `%s` interface name `%s` not found\", server.ID, interfaceName)\n\t}\n\treturn poolAddress, err\n}\n","sourceCodeStart":98,"sourceCodeEnd":129,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/utils.go#L98-L129","documentation":"Thrown by GetServerFixedIP when a server address entry of type 'fixed' contains an 'addr' key whose value is not a JSON string. Nova address maps are loosely typed interface{} values; a non-string addr breaks the string type assertion used to extract the pool IP.","triggerScenarios":"GetServerFixedIP (called by osBuildCloudInstanceGroup) walks server.Addresses[interfaceName], finds a fixed-type entry, gets addrMap[openstackAddress], but `fixedIP.(string)` fails — the addr value is a number, object, or other non-string type.","commonSituations":"Custom Neutron/SDN address extensions returning structured address objects; clouds with unusual address formats; future API changes where addr becomes an object; corrupted or mocked server payloads.","solutions":["Dump the server's Addresses (`openstack server show <id> -f json`) to see the actual addr type.","Update parsing to handle the actual shape (use gophercloud's typed ServerAddress struct or a recursive string extraction).","Verify the network uses standard fixed IP assignment; report nonstandard formats to the cloud provider."],"exampleFix":"// before\nif fixedIPStr, ok := fixedIP.(string); ok {\n    poolAddress = fixedIPStr\n} else {\n    err = fmt.Errorf(\"Fixed IP was not a string: %v\", fixedIP)\n}\n// after\nswitch v := fixedIP.(type) {\ncase string:\n    poolAddress = v\ncase map[string]interface{}:\n    if s, ok := v[\"addr\"].(string); ok {\n        poolAddress = s\n    }\ndefault:\n    err = fmt.Errorf(\"Fixed IP was not a string: %T %v\", fixedIP, fixedIP)\n}","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"func fixedIPString(v interface{}) (string, bool) {\n    switch s := v.(type) {\n    case string:\n        return s, true\n    case map[string]interface{}:\n        a, ok := s[\"addr\"]\n        if !ok {\n            return \"\", false\n        }\n        return fixedIPString(a)\n    }\n    return \"\", false\n}","tryCatchPattern":"if ip, ok := fixedIPString(fixedIP); ok {\n    poolAddress = ip\n} else {\n    err = fmt.Errorf(\"Fixed IP was not a string: %T %v\", fixedIP, fixedIP)\n}","preventionTips":["Use gophercloud's typed address structs instead of raw map[string]interface{}","Log the full %#v of the address entry when the assertion fails","Test parsing against the actual cloud's `openstack server show` output"],"tags":["openstack","nova","networking","type-assertion"],"backgroundTag":"unexpected-json-type","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"}