fix: record original upstream status code when failover exhausted (#1128)
When all failover accounts are exhausted, handleFailoverExhausted maps the upstream status code (e.g. 403) to a client-facing code (e.g. 502) but did not write the original code to the gin context. This caused ops error logs to show the mapped code instead of the real upstream code. Call SetOpsUpstreamError before mapUpstreamError in all failover- exhausted paths so that ops_error_logger captures the true upstream status code and message. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,13 @@ func SetOpsLatencyMs(c *gin.Context, key string, value int64) {
|
||||
c.Set(key, value)
|
||||
}
|
||||
|
||||
// SetOpsUpstreamError is the exported wrapper for setOpsUpstreamError, used by
|
||||
// handler-layer code (e.g. failover-exhausted paths) that needs to record the
|
||||
// original upstream status code before mapping it to a client-facing code.
|
||||
func SetOpsUpstreamError(c *gin.Context, upstreamStatusCode int, upstreamMessage, upstreamDetail string) {
|
||||
setOpsUpstreamError(c, upstreamStatusCode, upstreamMessage, upstreamDetail)
|
||||
}
|
||||
|
||||
func setOpsUpstreamError(c *gin.Context, upstreamStatusCode int, upstreamMessage, upstreamDetail string) {
|
||||
if c == nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user