Sakurasan
20f365d11a
fix: 识别上游 HTTP 200 错误体,正确记账并返回 502
问题:OpenRouter 等上游超时时返回 HTTP 200 但响应体/SSE 内含
error 字段(如 {"error":{"code":504}}),网关只检查 StatusCode>=400,
导致:1) 客户端收到假 200 + 空内容;2) 用量被错误记为 success。
修复:
- bufferResponse 检测 JSON 错误体(openai 风格 error / anthropic 风格 type=error),
识别时以 502 返回给客户端,并向 Dispatch 返回错误码
- streamResponse 扫描 SSE data 载荷中的 error 字段,识别时返回错误码
- Dispatch 对带错误码的响应按失败记账(status=error, error_code=upstream_error),
不产生费用
2026-09-01 03:31:55 +08:00
..
2026-09-01 02:55:55 +08:00
2026-08-30 12:02:52 +08:00
2026-09-01 00:46:05 +08:00
2026-08-30 12:02:52 +08:00
2026-09-01 00:46:05 +08:00
2026-09-01 02:55:55 +08:00
2026-08-30 12:02:52 +08:00
2026-08-30 12:02:52 +08:00
2026-09-01 03:31:55 +08:00
2026-09-01 00:46:05 +08:00
2026-09-01 02:32:31 +08:00
2026-09-01 02:32:31 +08:00
2026-08-30 12:02:52 +08:00