rancher/rancher · error

ServerError

ServerError

Error message

error parsing response

What it means

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.

Source

Thrown at pkg/api/norman/customization/alibaba/listers.go:437

			return nil, http.StatusBadRequest, errors.New("getUpgradableVersions param value not valid")
		}
		request.QueryUpgradableVersion = tea.Bool(getUpgradableVersionsVal)
	}

	resp, err := client.DescribeKubernetesVersionMetadataWithContext(req.Context(), request, map[string]*string{}, &dara.RuntimeOptions{})
	if err != nil {
		status, err := handleSDKError(err)
		return nil, status, err
	}

	if resp == nil || resp.Body == nil {
		return nil, http.StatusInternalServerError, errors.New(emptyResponseError)
	}

	bytes, err := json.Marshal(resp.Body)
	if err != nil {
		logrus.Debugf("[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v", err)
		return nil, httperror.ServerError.Status, errors.New("error parsing response")
	}

	return bytes, http.StatusOK, nil
}

func describeZones(capabilities *Capabilities, req *http.Request) ([]byte, int, error) {
	client, err := CreateECSClient(capabilities.AccessKeyID, capabilities.AccessKeySecret, capabilities.RegionID)
	if err != nil {
		return nil, http.StatusInternalServerError, err
	}

	request := &ecs.DescribeZonesRequest{
		RegionId: &capabilities.RegionID,
	}
	acceptLanguage := req.URL.Query().Get("acceptLanguage")
	if acceptLanguage != "" {
		request.AcceptLanguage = &acceptLanguage
	}

View on GitHub (pinned to 932558d4e6)

Solutions

  1. 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()').
  2. Check go.mod for the alibaba cloud SDK (darabonba/tea/ecs) revision against the version this Rancher release pins; align or upgrade both together.
  3. 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.
  4. If marshaling legitimately fails, translate to a 502 Bad Gateway with the underlying cause rather than a bare 500, so callers can retry.

Example fix

// before
bytes, err := json.Marshal(resp.Body)
if err != nil {
    logrus.Debugf("[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v", err)
    return nil, httperror.ServerError.Status, errors.New("error parsing response")
}
return bytes, http.StatusOK, nil

// after (consistent with sibling handlers that stream the SDK body)
if s, ok := resp.Body.(interface{ String() string }); ok {
    return []byte(s.String()), http.StatusOK, nil
}
bytes, err := json.Marshal(resp.Body)
if err != nil {
    logrus.Errorf("[alibaba-handler] error parsing describeKubernetesVersionMetadata: %v", err)
    return nil, http.StatusBadGateway, fmt.Errorf("error parsing response: %w", err)
}
return bytes, http.StatusOK, nil
Defensive patterns

Strategy: try-catch

Try / catch

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 }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of rancher/rancher@932558d4e6 (2026-08-16). Data as JSON: /api/errors/800c0d96abb024f9. Report an issue: GitHub.