feat: hide upstream error message#1640
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces an "Upstream Error Display" policy, allowing administrators to control whether raw provider errors are shown to API users, hidden, or replaced with custom messages. The implementation includes frontend UI updates, GraphQL schema changes, and backend logic to intercept and transform errors in both standard and streaming chat completions. Review feedback suggests optimizing the backend implementation by caching transformed errors in the stream handler to avoid redundant policy lookups and transformations. Additionally, it was noted that the error detection logic currently relies on fragile string matching and should be replaced with more robust error type checking.
Greptile SummaryThis PR adds an admin-configurable policy for how upstream provider errors are exposed to API users: pass through (default), hide with a generic message, or replace with a custom message. The pipeline layer tags upstream errors with a sentinel
Confidence Score: 5/5Safe to merge. The core masking logic is well-guarded: quota errors are excluded at two levels, non-upstream errors are skipped via the UpstreamError sentinel, and all three API handler paths now consistently apply the policy. The implementation correctly replaced the previous string-based error classification with a struct-based sentinel. Video and Doubao handlers now go through transformOrchestratorError. No data integrity, auth, or correctness regressions are introduced. The only finding is a minor redundant policy read in the streaming error path. No files require special attention beyond the minor style note on upstream_error_policy.go. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
REQ[Incoming API Request] --> ORCH[Orchestrator]
ORCH -->|error| TE[transformOrchestratorError]
TE --> WQ[wrapQuotaExhaustedAsResponseError]
WQ --> AUP[applyUpstreamErrorPolicy]
AUP -->|IsUpstreamError? NO| PASS1[Pass through unchanged]
AUP -->|IsUpstreamError? YES| MASK[Replace message]
MASK --> TFE[Inbound.TransformError]
PASS1 --> TFE
TFE --> RESP[JSON response]
ORCH -->|stream| UES[upstreamErrorStream wrapper]
UES --> ERR[Err called after stream]
ERR -->|nil| OK[No error]
ERR -->|non-nil| WAUP[WrapUpstreamError + applyUpstreamErrorPolicy]
WAUP -->|quota err| PASSQ[Quota: always pass through]
WAUP -->|hidden/custom| MASKSM[Replace message]
WAUP -->|passthrough| PASS2[Pass through unchanged]
Reviews (3): Last reviewed commit: "fix" | Re-trigger Greptile |
Uh oh!
There was an error while loading. Please reload this page.