Skip to content

feat(error-passthrough): support local account selection errors#3340

Open
techotaku39 wants to merge 1 commit into
Wei-Shaw:mainfrom
techotaku39:feat/error-passthrough-local-account-selection
Open

feat(error-passthrough): support local account selection errors#3340
techotaku39 wants to merge 1 commit into
Wei-Shaw:mainfrom
techotaku39:feat/error-passthrough-local-account-selection

Conversation

@techotaku39

Copy link
Copy Markdown

Summary

This PR extends error passthrough rules to local account-selection failures, especially no available accounts errors that happen before an upstream request is made.

Previously, local routing failures returned hardcoded messages such as Service temporarily unavailable or No available accounts, so administrators could not customize these client-facing responses through error passthrough rules.

With this change, administrators can create an error passthrough rule for local account-selection failures, customize the response status code, and render a user-friendly message with best-effort account reset details.

Changes

  • Apply error passthrough rules to local account-selection failures.
  • Cover generic gateway paths:
    • /messages
    • /chat/completions
    • /responses
    • count tokens
  • Cover OpenAI gateway paths:
    • /responses
    • /messages
    • /chat/completions
    • /embeddings
    • account slot acquisition failures
  • Add account-selection error template rendering helpers.
  • Add tests for:
    • default behavior when no rule matches
    • custom rule matching
    • non-OpenAI platform account summary generation
    • OpenAI/Codex quota summary compatibility
  • Add frontend hint text for custom message template variables.

Usage example

Administrators can create a rule like:

  • status code: 503
  • keyword: no available accounts
  • match mode: all
  • custom response code: 429
  • custom message:
    账户额度已用完,最快重置时间:{{next_reset_at}},账号:{{next_reset_account}}。详情:{{account_summary}}

Supported template variables:

  • {{next_reset_at}}
  • {{next_reset_account}}
  • {{account_summary}}

The account summary is best-effort and only includes non-secret metadata such as account name, platform, scheduling status, quota state, rate-limit reset time, overload time, temporary unschedulable reason, and Codex/OpenAI quota snapshots when available.

Testing

  • go test -tags=unit ./...
  • go test -tags=integration ./...
  • golangci-lint run --timeout=30m
  • pnpm run lint:check
  • pnpm run typecheck
  • critical frontend vitest suite

Notes

No database schema changes are required.
No Ent code generation is required.
No frontend dependency changes are required.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA).

To sign, please reply with the following comment:

I have read the CLA Document and I hereby sign the CLA

You only need to sign once — it will be valid for all your future contributions to this project.


I have read the CLA Document and I hereby sign the CLA


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant