{"record":{"id":"800c0d96abb024f9","repo":"rancher/rancher","slug":"servererror","errorCode":"ServerError","errorMessage":"error parsing response","messagePattern":"error parsing response","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"pkg/api/norman/customization/alibaba/listers.go","lineNumber":437,"sourceCode":"\t\t\treturn nil, http.StatusBadRequest, errors.New(\"getUpgradableVersions param value not valid\")\n\t\t}\n\t\trequest.QueryUpgradableVersion = tea.Bool(getUpgradableVersionsVal)\n\t}\n\n\tresp, err := client.DescribeKubernetesVersionMetadataWithContext(req.Context(), request, map[string]*string{}, &dara.RuntimeOptions{})\n\tif err != nil {\n\t\tstatus, err := handleSDKError(err)\n\t\treturn nil, status, err\n\t}\n\n\tif resp == nil || resp.Body == nil {\n\t\treturn nil, http.StatusInternalServerError, errors.New(emptyResponseError)\n\t}\n\n\tbytes, err := json.Marshal(resp.Body)\n\tif err != nil {\n\t\tlogrus.Debugf(\"[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v\", err)\n\t\treturn nil, httperror.ServerError.Status, errors.New(\"error parsing response\")\n\t}\n\n\treturn bytes, http.StatusOK, nil\n}\n\nfunc describeZones(capabilities *Capabilities, req *http.Request) ([]byte, int, error) {\n\tclient, err := CreateECSClient(capabilities.AccessKeyID, capabilities.AccessKeySecret, capabilities.RegionID)\n\tif err != nil {\n\t\treturn nil, http.StatusInternalServerError, err\n\t}\n\n\trequest := &ecs.DescribeZonesRequest{\n\t\tRegionId: &capabilities.RegionID,\n\t}\n\tacceptLanguage := req.URL.Query().Get(\"acceptLanguage\")\n\tif acceptLanguage != \"\" {\n\t\trequest.AcceptLanguage = &acceptLanguage\n\t}","sourceCodeStart":419,"sourceCodeEnd":455,"githubUrl":"https://github.com/rancher/rancher/blob/932558d4e68565aff2d2f36e89ec4a391b06e7c5/pkg/api/norman/customization/alibaba/listers.go#L419-L455","documentation":"Thrown by the Alibaba Cloud DescribeKubernetesVersionMetadata proxy handler in Rancher when json.Marshal(resp.Body) fails after the SDK call itself succeeded. It means the SDK response object contains a value Go's encoding/json cannot serialize (NaN/Inf float fields, func/chan fields, cyclic references, or a custom MarshalJSON that errors). The root cause is logged at Debug level with the prefix '[alibaba-handler] error parsing describeKubernetesVersionMetadata', but the client only sees a generic 500 ServerError.","triggerScenarios":"POST to the Rancher cloud metadata handler that proxies ecs.DescribeKubernetesVersionMetadata when the alibaba-cloud-sdk-go/tea structures returned for the region contain a non-serializable value. Typically appears after an SDK version upgrade changed the response struct, or when a data race corrupts the response object before marshaling.","commonSituations":"Mismatched alibaba cloud SDK and Rancher handler versions; a region returning metadata with fields the pinned SDK maps oddly; rare memory corruption or shared-response mutation in tests. The Debugf cause is invisible unless log level is debug, so teams see an unexplained 500.","solutions":["Set logging level to debug and reproduce: the '[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v' line right above the return contains the actual json.Marshal error (e.g. 'json: unsupported type: func()').","Check go.mod for the alibaba cloud SDK (darabonba/tea/ecs) revision against the version this Rancher release pins; align or upgrade both together.","If the response body is a *tea/string-body type like the sibling handlers use, return []byte(resp.Body.String()) instead of json.Marshal, matching describeZones/describeImageSupportedInstanceTypes in the same file.","If marshaling legitimately fails, translate to a 502 Bad Gateway with the underlying cause rather than a bare 500, so callers can retry."],"exampleFix":"// before\nbytes, err := json.Marshal(resp.Body)\nif err != nil {\n    logrus.Debugf(\"[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v\", err)\n    return nil, httperror.ServerError.Status, errors.New(\"error parsing response\")\n}\nreturn bytes, http.StatusOK, nil\n\n// after (consistent with sibling handlers that stream the SDK body)\nif s, ok := resp.Body.(interface{ String() string }); ok {\n    return []byte(s.String()), http.StatusOK, nil\n}\nbytes, err := json.Marshal(resp.Body)\nif err != nil {\n    logrus.Errorf(\"[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v\", err)\n    return nil, http.StatusBadGateway, fmt.Errorf(\"error parsing response: %w\", err)\n}\nreturn bytes, http.StatusOK, nil","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"err, ok := err.(*httperror.APIError); if ok && err.Status == httperror.ServerError.Status && strings.Contains(err.Message, \"error parsing response\") { log rancher-server at debug level and retry once; a marshal failure of a successful SDK response is frequently transient per-object }","preventionTips":["Pin the alibaba cloud SDK and darabonba runtime to the versions tested by your Rancher release","Run rancher-server at debug log level when exercising Alibaba metadata endpoints so the underlying json.Marshal cause is captured","Prefer handlers that stream resp.Body.String() over re-marshaling SDK structs in any forked code"],"tags":["go","alibaba-cloud","sdk","json","serialization","rancher"],"backgroundTag":null,"analyzedSha":"932558d4e68565aff2d2f36e89ec4a391b06e7c5","analyzedAt":"2026-08-16T04:37:02.125Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}