Skip to content

Commit 76795a6

Browse files
committed
fix(native-api): 修复批量嵌入子请求网络异常未捕获导致 500 的问题;
在 _vertex_batch_embed._single 中为 client.send() 添加与 _vertex_single_embed 一致的 httpx 网络异常处理(TimeoutException/ConnectError/ReadError/RemoteProtocolError), 确保子请求超时或连接失败时返回 502 而非触发未处理异常。 🤖 Generated with [Claude Code](https://github.com/claude), [CodeX](https://openai.com), [Gemini](https://github.com/apps/gemini-code-assist) Co-Authored-By: Aurelius Huang<threefish.ai@gmail.com>
1 parent efb9ae6 commit 76795a6

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎src/coding/proxy/native_api/handler.py‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,7 +553,15 @@ async def _single(req_body: dict) -> tuple[dict, int]:
553553
content=vertex_body,
554554
headers=upstream_headers,
555555
)
556-
resp = await client.send(req, stream=False)
556+
try:
557+
resp = await client.send(req, stream=False)
558+
except (
559+
httpx.TimeoutException,
560+
httpx.ConnectError,
561+
httpx.ReadError,
562+
httpx.RemoteProtocolError,
563+
) as exc:
564+
return {"error": {"message": f"upstream unreachable: {exc}"}}, 502
557565
try:
558566
return resp.json(), resp.status_code
559567
except Exception:

0 commit comments

Comments
 (0)