{"record":{"id":"60e1469f03a02ad5","repo":"kubernetes/kops","slug":"could-not-extract-flavors-v","errorCode":null,"errorMessage":"Could not extract flavors: %v","messagePattern":"Could not extract flavors: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"upup/pkg/fi/cloudup/openstack/utils.go","lineNumber":69,"sourceCode":"\t}\n\treturn s[i].RAM < s[j].RAM\n}\n\nfunc (c *openstackCloud) DefaultInstanceType(cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error) {\n\treturn defaultInstanceType(c, cluster, ig)\n}\n\nfunc defaultInstanceType(c OpenstackCloud, cluster *kops.Cluster, ig *kops.InstanceGroup) (string, error) {\n\tflavorPage, err := flavors.ListDetail(c.ComputeClient(), flavors.ListOpts{\n\t\tMinRAM: 1024,\n\t}).AllPages(context.TODO())\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Could not list flavors: %v\", err)\n\t}\n\tvar fList flavorList\n\tfList, err = flavors.ExtractFlavors(flavorPage)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"Could not extract flavors: %v\", err)\n\t}\n\tsort.Sort(&fList)\n\n\tvar candidates flavorList\n\tswitch {\n\tcase ig.Spec.Role.HasControlPlane():\n\t\t// Requirements based on awsCloudImplementation.DefaultInstanceType\n\t\tfor _, flavor := range fList {\n\t\t\tif flavor.RAM >= 4096 && flavor.VCPUs >= 1 {\n\t\t\t\tcandidates = append(candidates, flavor)\n\t\t\t}\n\t\t}\n\n\tcase ig.Spec.Role.HasNode():\n\t\tfor _, flavor := range fList {\n\t\t\tif flavor.RAM >= 4096 && flavor.VCPUs >= 2 {\n\t\t\t\tcandidates = append(candidates, flavor)\n\t\t\t}","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/upup/pkg/fi/cloudup/openstack/utils.go#L51-L87","documentation":"This error wraps a failure from gophercloud's flavors.ExtractFlavors when decoding a Nova flavor-list pagination page into a flavorList. The HTTP list call succeeded, but the response body could not be decoded into the expected flavor schema (wrong fields, non-JSON/HTML proxy error page, schema drift). It aborts defaultInstanceType's flavor search so no default instance type can be chosen for the instance group.","triggerScenarios":"defaultInstanceType (called by DefaultInstanceType) invokes flavors.ExtractFlavors(flavorPage) after a successful flavors.List; ExtractFlavors returns a decode error which is wrapped here: Nova returning legacy/nonstandard flavor JSON, a proxy/LB returning an HTML error page, or gophercloud schema mismatch.","commonSituations":"Older or non-standard OpenStack clouds whose flavor listing deviates from gophercloud's expected schema; middleware (auth interceptors, load balancers) intercepting Nova responses; wrong compute endpoint in the service catalog returning unexpected payloads; outdated gophercloud version vs the target OpenStack release.","solutions":["Inspect the wrapped inner error (%v) to see the exact JSON decode failure and which page failed.","Verify with `openstack flavor list` using the same credentials that Nova's flavor endpoint returns valid JSON.","Upgrade/align the gophercloud version with the target OpenStack release to fix schema mismatches.","Bypass or fix any proxy/LB in front of Nova that could return non-JSON error pages."],"exampleFix":"// before\nfList, err = flavors.ExtractFlavors(flavorPage)\nif err != nil {\n    return \"\", fmt.Errorf(\"Could not extract flavors: %v\", err)\n}\n// after\nfList, err = flavors.ExtractFlavors(flavorPage)\nif err != nil {\n    return \"\", fmt.Errorf(\"extracting flavors page: %w\", err)\n}","handlingStrategy":"retry","validationCode":"resp, err := novaClient.Get(flavorListURL, nil, nil)\nif err != nil || !strings.Contains(resp.Header.Get(\"Content-Type\"), \"application/json\") {\n    return fmt.Errorf(\"flavor endpoint did not return JSON\")\n}","typeGuard":"func isJSONPage(page gophercloud.Page) bool {\n    return page != nil && page.GetBody() != nil\n}","tryCatchPattern":"fList, err = flavors.ExtractFlavors(flavorPage)\nif err != nil {\n    return \"\", fmt.Errorf(\"Could not extract flavors: %w\", err) // inspect wrapped cause\n}","preventionTips":["Keep gophercloud version aligned with the target OpenStack release","Confirm `openstack flavor list` works with the same credentials before provisioning","Check Content-Type of the response to catch proxy/HTML error pages early"],"tags":["openstack","nova","gophercloud","json-decode"],"backgroundTag":"schema-validation-failed","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"}