SigNoz/signoz · error · basemodel.ApiError

couldn't unmarshal gateway response into %T

Error message

couldn't unmarshal gateway response into %T

What it means

The gateway response body was read successfully but does not JSON-decode into the expected ResponseType (the message includes the concrete Go type via %T). Field type mismatches or malformed JSON both trigger it.

Source

Thrown at ee/query-service/app/api/cloudIntegrations.go:353

	}

	response, err := client.Do(req)
	if err != nil {
		return nil, basemodel.InternalError(fmt.Errorf("couldn't make request: %w", err))
	}

	defer response.Body.Close()

	respBody, err := io.ReadAll(response.Body)
	if err != nil {
		return nil, basemodel.InternalError(fmt.Errorf("couldn't read response: %w", err))
	}

	var resp ResponseType

	err = json.Unmarshal(respBody, &resp)
	if err != nil {
		return nil, basemodel.InternalError(fmt.Errorf(
			"couldn't unmarshal gateway response into %T", resp,
		))
	}

	return &resp, nil
}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Log the raw respBody alongside the target type to spot the mismatch
  2. Compare the actual payload to the struct definition and update it
  3. Confirm the gateway is not returning an error body with 200
Defensive patterns

Strategy: validation

Validate before calling

var probe map[string]any
if err := json.Unmarshal(body, &probe); err != nil {
    // not JSON at all — fail before typed decode
}

Try / catch

Decode errors should capture the raw body and target type (%T already in the message) to pinpoint the field mismatch; fail fast rather than retry.

Prevention

When it happens

Trigger: Gateway returns a payload whose shape differs from the generic response struct used by requestAndParseResponse — e.g. a string where a number is expected, or an error page body.

Common situations: Upstream API schema drift, gateway returning HTML/text errors with a 200 status, or a new field type changing between versions.

Related errors


AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28). Data as JSON: /api/errors/9213356d76ea8d02. Report an issue: GitHub.