jlcodes99/cockpit-tools · error

加载账号失败: {}

Error message

加载账号失败: {}

What it means

Error mapping in list_accounts (cockpit-core account module): load_account failed for one index entry while listing all accounts; the error is formatted as '加载账号失败: {}' (with the per-account error interpolated), logged, and that account is skipped so the rest of the list still returns. Typical causes are a missing or corrupt per-account file referenced by the account index.

Source

Thrown at crates/cockpit-core/src/modules/account.rs:316

        .lock()
        .map_err(|e| format!("获取账号列表锁失败: {}", e))?;

    if let Some(accounts) = read_list_accounts_cache() {
        return Ok(accounts);
    }

    modules::logger::log_info("开始列出账号...");
    let index = load_account_index()?;
    let mut accounts = Vec::new();

    for summary in &index.accounts {
        match load_account(&summary.id) {
            Ok(mut account) => {
                let _ = modules::quota_cache::apply_cached_quota(&mut account, "authorized");
                accounts.push(account);
            }
            Err(e) => {
                modules::logger::log_error(&format!("加载账号失败: {}", e));
            }
        }
    }

    write_list_accounts_cache(&accounts);
    Ok(accounts)
}

fn non_empty(value: Option<&str>) -> Option<&str> {
    value.map(str::trim).filter(|v| !v.is_empty())
}

fn is_strict_account_identity_match(existing: &Account, email: &str, token: &TokenData) -> bool {
    if let Some(session_id) = non_empty(token.session_id.as_deref()) {
        if non_empty(existing.token.session_id.as_deref()) == Some(session_id) {
            return true;
        }
    }

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Inspect the interpolated cause (IO error, JSON parse failure) for the affected account id
  2. Remove or repair the stale account file/index entry so list_accounts stops skipping it
  3. Restore the account from backup or re-authenticate to recreate it
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/cockpit-core/src/modules/account.rs:316 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05). Data as JSON: /api/errors/1dda0a36b21d202b. Report an issue: GitHub.