Skip to content

Commit 550b979

Browse files
authored
Merge pull request Wei-Shaw#1146 from DaydreamCoding/fix/test-403-error-status
fix(test): 测试连接收到 403 时将账号标记为 error 状态
2 parents 3878a5a + c1717c9 commit 550b979

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

backend/internal/service/account_test_service.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,14 @@ func (s *AccountTestService) testClaudeAccountConnection(c *gin.Context, account
308308

309309
if resp.StatusCode != http.StatusOK {
310310
body, _ := io.ReadAll(resp.Body)
311-
return s.sendErrorAndEnd(c, fmt.Sprintf("API returned %d: %s", resp.StatusCode, string(body)))
311+
errMsg := fmt.Sprintf("API returned %d: %s", resp.StatusCode, string(body))
312+
313+
// 403 表示账号被上游封禁,标记为 error 状态
314+
if resp.StatusCode == http.StatusForbidden {
315+
_ = s.accountRepo.SetError(ctx, account.ID, errMsg)
316+
}
317+
318+
return s.sendErrorAndEnd(c, errMsg)
312319
}
313320

314321
// Process SSE stream

0 commit comments

Comments
 (0)