AIStudio2API icon indicating copy to clipboard operation
AIStudio2API copied to clipboard

[Bug] Service fails to start ("No usable account") if a disabled account has cached models requiring higher tier

Open ApePrime opened this issue 1 week ago • 1 comments

发生了什么 / What happened

Environment

  • Version: v0.3.12 (Windows amd64)
  • WAA Backend: SpiderMonkey

Description

When a Pro/Ultra account that has previously cached high-tier models (such as deep-research-preview-04-2026) is set to Disabled, and only Free accounts remain enabled, the generation service fails to start with the error:

"No usable account. Add or enable an account, or check the status of existing accounts on the Accounts page"

In runtime/logs/aistudio2api.log:

{
  "level": "ERROR",
  "msg": "生成服务启动失败",
  "error": "没有可预热的账户: 模型 deep-research-preview-04-2026 需要以下任一权益,启用的账户都不具备:付费 API key;Google AI Pro 或 Ultra 订阅"
}

Steps to Reproduce

  1. Add an account with Google AI Pro / Ultra subscription (it populates catalog.json with Pro-only models like deep-research-preview-04-2026).
  2. Add one or more Free accounts.
  3. Disable the Pro account (toggle to Disabled / enabled: false).
  4. Click Start service.

Expected Behavior

The service should start using only the enabled Free accounts, serving models available to them, while ignoring models that only belong to disabled accounts.

Actual Behavior

The service crashes into STOPPED state and refuses to launch.

Root Cause Analysis

In internal/app/worker_manager.go inside classifyBootstrapCandidates (~line 806):

for _, status := range manager.pool.Status() {
    models, err := manager.pool.BootstrapModels(status.ID)
    if err != nil {
        continue
    }
    for _, modelID := range models {
        if _, exists := seenModels[modelID]; exists {
            continue
        }
        seenModels[modelID] = struct{}{}
        modelIDs = append(modelIDs, modelID)
    }
}
  1. manager.pool.Status() returns all accounts, including disabled ones (status.Enabled == false). It reads BootstrapModels from catalog.json of disabled accounts, polluting modelIDs with Pro-only models.
  2. In the subsequent loop (~line 820), manager.pool.ClassifyCandidates() checks for eligible accounts among enabled accounts. Since none of the enabled accounts possess Pro/Ultra tier, it returns ModelAccessError.
  3. Instead of skipping the inaccessible model, classifyBootstrapCandidates immediately returns the error, aborting the entire bootstrap process.

Suggested Fix

  1. Skip disabled accounts when gathering bootstrap model IDs in classifyBootstrapCandidates:
for _, status := range manager.pool.Status() {
    if !status.Enabled {
        continue
    }
    models, err := manager.pool.BootstrapModels(status.ID)
    // ...
}
  1. Additionally, in the candidate classification loop, consider skipping models that return ModelAccessError rather than aborting the entire startup if other models have eligible accounts.

版本 / Version

v0.3.12

ApePrime avatar Nov 21 '26 13:11 ApePrime

alr fixed in v0.3.13, see https://github.com/Mag1cFall/AIStudio2API/issues/201

Mag1cFall avatar Nov 22 '26 00:11 Mag1cFall