sub2api icon indicating copy to clipboard operation
sub2api copied to clipboard

[Bug] OpenAI admin account test does not persist 429 rate-limit state, leaving stale 403 error data

Open KnowSky404 opened this issue 7 months ago • 2 comments

Summary

The OpenAI admin account test path can return 429 usage_limit_reached, but that result is not persisted back into account runtime state in the same way as the normal rate-limit handling flow.

In practice, this can leave an account with stale persisted 403 error data in the database, while live retesting already shows 429.

Observed behavior

For some OpenAI OAuth accounts:

  • persisted DB state remained:
    • status=error
    • error_message='Access forbidden (403): account may be suspended or lack permissions'

But live /api/v1/admin/accounts/:id/test returned:

  • 429 usage_limit_reached

This creates visible state drift between the real upstream result and the stored account status.

Root cause

In testOpenAIAccountConnection, non-200 responses are returned directly to the UI.

Currently:

  • 401 explicitly persists an account error
  • 429 is returned to the caller, but does not update account runtime state through the rate-limit persistence path in this flow

Meanwhile, the rate-limit service already has logic to parse and persist OpenAI 429 reset times.

Expected behavior

When the admin test path receives an OpenAI 429 usage_limit_reached, it should persist rate-limit state consistently, including fields such as:

  • rate_limited_at
  • rate_limit_reset_at

and it should avoid leaving stale 403 error data behind.

Relevant code

  • backend/internal/service/account_test_service.go
  • backend/internal/service/ratelimit_service.go

Proposed direction

We intend to help fix this by wiring the OpenAI admin test path into the existing rate-limit persistence/reconciliation flow, so retest results update runtime state instead of leaving stale error status in place.

KnowSky404 avatar Apr 21 '26 00:04 KnowSky404

Image

Image 不知是否是这个原因 openai的无法调用

mingtianquan avatar Apr 21 '26 14:04 mingtianquan

用到是工具是https://github.com/NanmiCoder/cc-haha

mingtianquan avatar Apr 21 '26 15:04 mingtianquan