fix(errors): 区分平台限流并保留上游状态码
原因:公开错误层将平台并发限流误标为上游限流,并把多种上游 4xx 统一压成 400,影响定位和客户端处理。 影响:新增公开错误 source,平台限流使用 gateway_rate_limited,上游请求按安全分类返回对应状态;数据库与管理端继续保留原始错误码、消息和状态用于审计。 验证:Go 全量测试、pnpm test、pnpm lint、pnpm build、pnpm openapi、gofmt 和 diff 检查均通过。
This commit is contained in:
@@ -1286,7 +1286,7 @@ func (s *Server) createTask(kind string, compatible bool) http.Handler {
|
||||
}
|
||||
status := http.StatusConflict
|
||||
if task.Status == "failed" || task.Status == "cancelled" {
|
||||
status = storedTaskErrorStatus(task.ErrorCode)
|
||||
status = taskErrorHTTPStatus(task)
|
||||
}
|
||||
writeTaskError(status, firstNonEmpty(task.ErrorMessage, task.Error, task.Message, "task is not complete"), nil, firstNonEmpty(task.ErrorCode, task.Status))
|
||||
return
|
||||
@@ -1706,6 +1706,9 @@ func statusFromRunError(err error) int {
|
||||
case errors.Is(err, store.ErrInsufficientWalletBalance):
|
||||
return http.StatusPaymentRequired
|
||||
default:
|
||||
if status := clients.ErrorResponseMetadata(err).StatusCode; status >= 400 && status <= 599 {
|
||||
return status
|
||||
}
|
||||
return http.StatusBadGateway
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user