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

@@ -20,6 +20,7 @@ from .base import (
ProviderUsage,
StreamChunk,
is_transient_by_name,
provider_error_summary,
)
_TRANSIENT_NAMES = frozenset(
@@ -103,7 +104,9 @@ class GeminiAdapter:
)
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
text = getattr(resp, "text", "") or ""
usage = _usage_from(getattr(resp, "usage_metadata", None))
@@ -126,5 +129,7 @@ class GeminiAdapter:
yield StreamChunk(usage=_usage_from(meta))
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