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
- Log the raw respBody alongside the target type to spot the mismatch
- Compare the actual payload to the struct definition and update it
- 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
- Keep response DTOs in sync with gateway API versions
- Pin versions and add contract tests for gateway schemas
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
- couldn't unmarshal deployment info response: error: %w
- couldn't search for cloudprovider ingestion key: status: %s,
- couldn't create cloudprovider ingestion key: status: %s, err
- couldn't serialize request payload to JSON: %w
- ErrCodeInvalidGatewayConfig
AI-assisted analysis of SigNoz/signoz@5069bf80b0 (2026-08-28).
Data as JSON: /api/errors/9213356d76ea8d02.
Report an issue: GitHub.