fix(canvas): 画布智能体 - 严格校验模型选择并修正任务与 DNS 错误诊断
This commit is contained in:
@@ -1203,6 +1203,7 @@ components:
|
||||
- timeout
|
||||
- internal
|
||||
- bad_gateway
|
||||
- upstream_dns_failed
|
||||
- model_capability_not_supported
|
||||
- model_price_not_configured
|
||||
- model_route_unavailable
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"errors"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"net/url"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
@@ -40,6 +41,20 @@ func TestFailServiceProjectsAppError(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailServiceProjectsDNSFailureWithoutTransportDetails(t *testing.T) {
|
||||
recorder, context := responseTestContext()
|
||||
err := service.WrapAppError(http.StatusBadGateway, "外部服务域名解析失败,请检查渠道域名和后端 DNS 配置", errors.New("private-sentinel resolver failure"))
|
||||
err.Reason = service.ReasonUpstreamDNSFailed
|
||||
failService(context, &url.Error{Op: "Post", URL: "https://private-sentinel.invalid?token=private-sentinel", Err: err})
|
||||
response := decodeFailureEnvelope(t, recorder)
|
||||
if recorder.Code != http.StatusBadGateway || response.Code != service.CodeBadGateway || response.Reason != string(service.ReasonUpstreamDNSFailed) || response.Msg != err.Message {
|
||||
t.Fatalf("DNS response contract lost: %d %#v", recorder.Code, response)
|
||||
}
|
||||
if strings.Contains(recorder.Body.String(), "private-sentinel") {
|
||||
t.Fatal("raw transport details leaked into HTTP response")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFailServiceQuotaExceeded(t *testing.T) {
|
||||
recorder, context := responseTestContext()
|
||||
failService(context, service.QuotaExceeded("账号素材数量已达到 100 个上限"))
|
||||
|
||||
Reference in New Issue
Block a user