jlcodes99/cockpit-tools · error
加载账号失败: {}
Error message
加载账号失败: {} What it means
list_accounts() iterates the account index and calls load_account(&summary.id) for each entry; if a detail file cannot be loaded/parsed, the error is logged as '加载账号失败: {}' and that account is skipped. This means an account that exists in the index is missing or unreadable on disk. If ALL indexed accounts fail, list_accounts returns a hard error afterwards.
Source
Thrown at src-tauri/src/modules/account.rs:541
.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));
}
}
}
if !index.accounts.is_empty() && accounts.is_empty() {
return Err(format!(
"账号索引中有 {} 个账号,但详情文件均无法读取;已保留前端缓存,请从账号备份或本地账号文件恢复。",
index.accounts.len()
));
}
write_list_accounts_cache(&accounts);
Ok(accounts)
}
fn non_empty(value: Option<&str>) -> Option<&str> {
value.map(str::trim).filter(|v| !v.is_empty())
}View on GitHub (pinned to 1ed8b77992)
Solutions
- Check the logged inner error to see if it is file-missing, permission, or JSON parse; fix accordingly (restore the file, fix permissions).
- Restore account detail files from the app's backup/本地账号文件 as the error path itself suggests.
- Rebuild the account index so it no longer references missing detail files (re-import accounts).
- Check free disk space and that no sync tool (OneDrive/Dropbox) is locking or placeholder-ing the data directory.
Defensive patterns
Strategy: fallback
Validate before calling
// Before relying on list_accounts, ensure index entries have matching detail files // (pseudo-check in app code): for each index id, verify the account JSON file exists and parses.
Try / catch
match list_accounts() {
Ok(accounts) => accounts,
Err(e) => {
// partial data: skip broken accounts; total failure: restore from backup per the logged message
log_error(e); Vec::new()
}
} Prevention
- Never delete account detail files manually; use the app's remove-account flow so the index stays in sync.
- Exclude the data directory from file-sync tools that can create conflicts/partial files.
- Keep recent account backups and restore them when the index/detail mismatch appears.
- Watch for disk-full or crash-interrupted writes that leave half-written account files.
When it happens
Trigger: load_account fails for a summary.id: the account detail JSON file was deleted, renamed, corrupted, or unreadable (permissions), or deserialization fails because the schema changed; index and detail files are out of sync.
Common situations: Manual deletion or sync-tool conflicts in the data directory, partial writes after a crash or disk-full event, restoring an index backup without matching detail files, or schema drift after an app upgrade.
Related errors
- 解析语言文件失败 {}: {}
- [WS] 保存服务状态失败: {}
- 读取文件失败 {:?}: {}
- Codex 导入因磁盘空间不足终止: label={}, imported={}, error={}
- invalidJsonMessage
AI-assisted analysis of jlcodes99/cockpit-tools@1ed8b77992 (2026-09-05).
Data as JSON: /api/errors/d4e00d2351e7a5a0.
Report an issue: GitHub.