fix(gateway): 适配器瞬时错误消息脱敏——只留类名+状态码不泄漏厂商响应体(CR-M2-2)

This commit is contained in:
Yaojia Wang
2026-07-08 12:58:25 +02:00
parent 32451a9bd0
commit 9439b97804
5 changed files with 129 additions and 6 deletions

View File

@@ -22,6 +22,7 @@ from .base import (
ProviderUsage,
StreamChunk,
is_transient_by_name,
provider_error_summary,
)
if TYPE_CHECKING:
@@ -131,7 +132,9 @@ class AnthropicAdapter:
return await self._complete_text(req, model)
except Exception as exc:
if _is_transient(exc):
raise TransientProviderError(str(exc), provider=self.provider) from exc
raise TransientProviderError(
provider_error_summary(exc), provider=self.provider
) from exc
raise
async def _complete_text(self, req: LlmRequest, model: str) -> ProviderResult:
@@ -187,5 +190,7 @@ class AnthropicAdapter:
yield StreamChunk(usage=_usage_from(usage))
except Exception as exc:
if _is_transient(exc):
raise TransientProviderError(str(exc), provider=self.provider) from exc
raise TransientProviderError(
provider_error_summary(exc), provider=self.provider
) from exc
raise