mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-12-06 00:05:30 +00:00
Root cause: PR #8385 applied the account error policy to the Chat Completions and Responses compatibility paths, but statuses outside the failover whitelist (for example 410 Gone from a migrated upstream base URL) still fell through to writeGatewayCCError/writeResponsesError with the upstream status and raw message. Global passthrough rules were not consulted either, so the client saw a bare 410 and the upstream migration hint. Change: - Apply applyErrorPassthroughRule before writing the non-failover error, so configured rules can remap status and message. - Record the original upstream status plus an http_error Ops event, then collapse unknown 4xx statuses (notably 410) into a generic 502 "Upstream request failed", matching /v1/messages and avoiding exposure of upstream migration hints. 400/404/413/422 keep their request-level status and sanitized message. - Leave 410 out of shouldFailoverUpstreamError to avoid changing retry semantics. Tests: extend the compat account policy regression to assert 410 -> 502 without the upstream message, request-level 4xx passthrough and Ops bookkeeping; add a passthrough-rule remap case for both entrypoints. Validation: - go build ./... - go test -tags=unit ./internal/service -count=1 - go test -tags=unit ./internal/service -run 'TestAnthropicCompat(AccountErrorPolicy|NonFailoverErrorAppliesPassthroughRule)$' -count=1