From a0f643da0e248d9d4c1db0c28729d027ee581e07 Mon Sep 17 00:00:00 2001 From: erio Date: Thu, 5 Mar 2026 21:03:08 +0800 Subject: [PATCH] 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. --- backend/internal/repository/claude_usage_service.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/internal/repository/claude_usage_service.go b/backend/internal/repository/claude_usage_service.go index e33f2e50..1264f6bb 100644 --- a/backend/internal/repository/claude_usage_service.go +++ b/backend/internal/repository/claude_usage_service.go @@ -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