SigNoz/signoz · warning

err.Error()

Error message

err.Error()

What it means

In render.Error, after mapping the error to an HTTP status (including 429 with Retry-After), the ErrorResponse body is json.Marshal'd. If that marshal fails (noted in-source as 'this should never be the case'), the handler falls back to http.Error with the marshal error and a raw 500.

Source

Thrown at pkg/http/render/render.go:122

		httpCode = http.StatusNotImplemented
	case errors.TypeForbidden:
		httpCode = http.StatusForbidden
	case errors.TypeCanceled:
		httpCode = statusClientClosedConnection
	case errors.TypeTimeout:
		httpCode = http.StatusGatewayTimeout
	case errors.TypeFatal:
		httpCode = http.StatusInternalServerError
	case errors.TypeLicenseUnavailable:
		httpCode = http.StatusUnavailableForLegalReasons
	case errors.TypeTooManyRequests:
		httpCode = http.StatusTooManyRequests
	}

	body, err := json.Marshal(&ErrorResponse{Status: StatusError.s, Error: errors.AsJSON(cause)})
	if err != nil {
		// this should never be the case
		http.Error(rw, err.Error(), http.StatusInternalServerError)
		return
	}

	// Retry-After carries the explicit delay declared via
	// errors.WithRetryAfter. Set it before WriteHeader so headers go on the wire.
	d := errors.RetryDelayOf(cause)
	if d.Seconds() > 0 {
		rw.Header().Set("Retry-After", strconv.Itoa(int(math.Ceil(d.Seconds()))))
	}

	rw.Header().Set("Content-Type", "application/json")
	rw.WriteHeader(httpCode)
	_, _ = rw.Write(body)
}

View on GitHub (pinned to 5069bf80b0)

Solutions

  1. Log the original cause before rendering so context is not lost if this path triggers
  2. Ensure custom error types only carry serializable fields
  3. Report as a bug if reproducible — this branch is documented as unreachable
Defensive patterns

Strategy: fallback

Try / catch

if _, err := json.Marshal(body); err != nil {
    http.Error(rw, "internal error", 500) // generic, log details server-side
}

Prevention

When it happens

Trigger: Essentially unreachable in practice: it requires ErrorResponse containing errors.AsJSON(cause) to be unmarshalable — e.g. a cause whose JSON encoding panics on unsupported types — while the original status/code information is lost.

Common situations: None realistic; if observed, it indicates a programming bug where the error cause carries non-serializable data (channels, cycles) rather than a user mistake.

Related errors


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