fix: keep 500 status for upstream errors, pass details in response body

Upstream errors like 401/429 must not be passed through as HTTP status
codes because the frontend routes on status (401 triggers JWT logout).
Keep HTTP 500 but include upstream error details in the message.
This commit is contained in:
erio
2026-03-05 21:03:08 +08:00
parent 99331a5285
commit a0f643da0e

View File

@@ -97,7 +97,7 @@ func (s *claudeUsageService) FetchUsageWithOptions(ctx context.Context, opts *se
if resp.StatusCode != http.StatusOK {
body, _ := io.ReadAll(resp.Body)
msg := fmt.Sprintf("API returned status %d: %s", resp.StatusCode, string(body))
return nil, infraerrors.New(resp.StatusCode, "UPSTREAM_ERROR", msg)
return nil, infraerrors.New(http.StatusInternalServerError, "UPSTREAM_ERROR", msg)
}
var usageResp service.ClaudeUsageResponse