fix(gemini): 移除空返图占位并暴露失败原因
Gemini 图片响应未包含可提取资源时,不再返回伪造占位图,改为非重试失败并保留安全拦截、候选结束状态和上游错误等结构化诊断。\n\n同步将诊断写入 HTTP 错误、任务结果、attempt 指标和日志,确保任务失败时不结算,并补充单元及 PostgreSQL 验收测试。\n\n验证:gofmt、go test ./... -count=1、go vet ./...、迁移安全检查、pnpm openapi。
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/easyai/easyai-ai-gateway/apps/api/internal/clients"
|
||||
)
|
||||
|
||||
func TestRunErrorDetailsExposeStructuredClientFailure(t *testing.T) {
|
||||
err := &clients.ClientError{
|
||||
Code: "gemini_image_output_missing",
|
||||
Message: "Gemini image response contains no extractable image: prompt blocked",
|
||||
Details: map[string]any{
|
||||
"provider": "gemini",
|
||||
"reason": "prompt_blocked",
|
||||
"promptBlockReason": "SAFETY",
|
||||
},
|
||||
}
|
||||
|
||||
details := runErrorDetails(err)
|
||||
if details["provider"] != "gemini" ||
|
||||
details["reason"] != "prompt_blocked" ||
|
||||
details["promptBlockReason"] != "SAFETY" {
|
||||
t.Fatalf("public error details lost Gemini extraction diagnostics: %+v", details)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user