fix(errors): 区分平台限流并保留上游状态码

原因:公开错误层将平台并发限流误标为上游限流,并把多种上游 4xx 统一压成 400,影响定位和客户端处理。

影响:新增公开错误 source,平台限流使用 gateway_rate_limited,上游请求按安全分类返回对应状态;数据库与管理端继续保留原始错误码、消息和状态用于审计。

验证:Go 全量测试、pnpm test、pnpm lint、pnpm build、pnpm openapi、gofmt 和 diff 检查均通过。
This commit is contained in:
2026-08-04 10:46:46 +08:00
parent 0f0998cbcf
commit fe56aa46b9
21 changed files with 289 additions and 22 deletions
+2 -1
View File
@@ -1363,7 +1363,7 @@ func (s *Service) runCandidate(
s.observeProviderQuotaWait(limitErr.Metric)
}
retryable := store.RateLimitRetryable(err)
clientErr := &clients.ClientError{Code: "rate_limit", Message: err.Error(), Retryable: retryable}
clientErr := &clients.ClientError{Code: clients.ErrorCode(err), Message: err.Error(), Retryable: retryable}
return clients.Response{}, &localRateLimitError{clientErr: clientErr, cause: err, retryAfter: localRateLimitRetryAfter(err)}
}
attemptOwnedLeases := append([]store.ConcurrencyLease(nil), limitResult.Leases...)
@@ -2026,6 +2026,7 @@ func (s *Service) failTask(ctx context.Context, taskID string, executionToken st
ExecutionToken: executionToken,
Code: code,
Message: message,
StatusCode: clients.ErrorResponseMetadata(cause).StatusCode,
Result: buildFailureResult(code, message, requestID, cause),
RequestID: requestID,
Metrics: metrics,