fix(provider): 延长媒体超时并终止超时轮转

将图像和视频的默认 HTTP/轮询超时分别提高到 20 分钟和 30 分钟。媒体任务超时后直接失败,不再重试、切换客户端或标记为 upstream_submission_unknown。OpenAI 图像端点遇到上游明确拒绝 response_format 时自动移除并缓存兼容结论。

验证:go test ./... -count=1;go vet ./...;gofmt;相关 Shell bash -n、ShellCheck 与发布脚本回归测试。
This commit is contained in:
2026-08-05 13:58:02 +08:00
parent 9ce9053d7b
commit dd10a807df
23 changed files with 336 additions and 55 deletions
+17 -4
View File
@@ -16,6 +16,19 @@ func TestProviderHTTPClientTimeoutAllowsLongRunningMediaRequests(t *testing.T) {
if client.Timeout != 10*time.Minute {
t.Fatalf("unexpected provider HTTP timeout: got %s want %s", client.Timeout, 10*time.Minute)
}
for _, test := range []struct {
kind string
want time.Duration
}{
{kind: "images.generations", want: 20 * time.Minute},
{kind: "images.edits", want: 20 * time.Minute},
{kind: "videos.generations", want: 30 * time.Minute},
{kind: "chat.completions", want: 10 * time.Minute},
} {
if got := providerHTTPClientForKind(client, test.kind).Timeout; got != test.want {
t.Fatalf("provider HTTP timeout for %s: got %s want %s", test.kind, got, test.want)
}
}
transport, ok := client.Transport.(*http.Transport)
if !ok {
t.Fatalf("provider transport type = %T, want *http.Transport", client.Transport)
@@ -51,7 +64,7 @@ func TestPlatformProxyModeNoneIgnoresEnvironmentProxy(t *testing.T) {
client, err := testProxyService(config.Config{}).httpClientForCandidate(store.RuntimeModelCandidate{
PlatformConfig: map[string]any{"networkProxy": map[string]any{"mode": "none"}},
}, false)
}, false, "chat.completions")
if err != nil {
t.Fatalf("build http client: %v", err)
}
@@ -86,7 +99,7 @@ func TestPlatformProxyModeCustomUsesConfiguredHTTPProxy(t *testing.T) {
client, err := testProxyService(config.Config{}).httpClientForCandidate(store.RuntimeModelCandidate{
PlatformConfig: map[string]any{"networkProxy": map[string]any{"mode": "custom", "httpProxy": proxy.URL}},
}, false)
}, false, "chat.completions")
if err != nil {
t.Fatalf("build http client: %v", err)
}
@@ -121,7 +134,7 @@ func TestPlatformProxyBypassIDUsesDirectConnection(t *testing.T) {
}).httpClientForCandidate(store.RuntimeModelCandidate{
PlatformID: "official-gemini-platform",
PlatformConfig: map[string]any{"networkProxy": map[string]any{"mode": "custom", "httpProxy": proxy.URL}},
}, false)
}, false, "chat.completions")
if err != nil {
t.Fatalf("build bypassed http client: %v", err)
}
@@ -153,7 +166,7 @@ func TestPlatformProxyModeGlobalUsesConfiguredGlobalHTTPProxy(t *testing.T) {
client, err := testProxyService(config.Config{GlobalHTTPProxy: proxy.URL}).httpClientForCandidate(store.RuntimeModelCandidate{
PlatformConfig: map[string]any{"networkProxy": map[string]any{"mode": "global"}},
}, false)
}, false, "chat.completions")
if err != nil {
t.Fatalf("build http client: %v", err)
}