mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-10-07 16:37:52 +08:00
The /v1/images/generations and /v1/images/edits paths routed every non-failover upstream error through the generic handleErrorResponse, whose final switch collapses anything that isn't 401/402/403/429 into a hardcoded 502 "Upstream request failed" — discarding the actual upstream status code, type, code, message, and param. So a gpt-image-2 400 (invalid_request_error, moderation, unsupported parameter, ...) reached the client as an opaque 502. The sibling Chat Completions and Messages compat paths already avoid this via handleCompatErrorResponse, which preserves the real status and message. Add the equivalent for images: handleOpenAIImagesErrorResponse keeps all existing side-effects (ops logging, error-passthrough rules, ShouldHandleErrorCode, account-disable/secondary-failover) but surfaces the real upstream status + type/code/message/param by reusing the existing OpenAIImagesUpstreamError machinery. Both forward paths now call it instead of handleErrorResponse for non-failover errors. Failover behavior (5xx / 401 / 403 / 429 / 529) is unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>