{"record":{"id":"d4e00d2351e7a5a0","repo":"jlcodes99/cockpit-tools","slug":"error-d4e00d","errorCode":null,"errorMessage":"加载账号失败: {}","messagePattern":"加载账号失败: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/src/modules/account.rs","lineNumber":541,"sourceCode":"        .lock()\n        .map_err(|e| format!(\"获取账号列表锁失败: {}\", e))?;\n\n    if let Some(accounts) = read_list_accounts_cache() {\n        return Ok(accounts);\n    }\n\n    modules::logger::log_info(\"开始列出账号...\");\n    let index = load_account_index()?;\n    let mut accounts = Vec::new();\n\n    for summary in &index.accounts {\n        match load_account(&summary.id) {\n            Ok(mut account) => {\n                let _ = modules::quota_cache::apply_cached_quota(&mut account, \"authorized\");\n                accounts.push(account);\n            }\n            Err(e) => {\n                modules::logger::log_error(&format!(\"加载账号失败: {}\", e));\n            }\n        }\n    }\n\n    if !index.accounts.is_empty() && accounts.is_empty() {\n        return Err(format!(\n            \"账号索引中有 {} 个账号，但详情文件均无法读取；已保留前端缓存，请从账号备份或本地账号文件恢复。\",\n            index.accounts.len()\n        ));\n    }\n\n    write_list_accounts_cache(&accounts);\n    Ok(accounts)\n}\n\nfn non_empty(value: Option<&str>) -> Option<&str> {\n    value.map(str::trim).filter(|v| !v.is_empty())\n}","sourceCodeStart":523,"sourceCodeEnd":559,"githubUrl":"https://github.com/jlcodes99/cockpit-tools/blob/1ed8b77992d62ca81fabf744deb0839ad361d5bf/src-tauri/src/modules/account.rs#L523-L559","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Before relying on list_accounts, ensure index entries have matching detail files\n// (pseudo-check in app code): for each index id, verify the account JSON file exists and parses.","typeGuard":null,"tryCatchPattern":"match list_accounts() {\n    Ok(accounts) => accounts,\n    Err(e) => {\n        // partial data: skip broken accounts; total failure: restore from backup per the logged message\n        log_error(e); Vec::new()\n    }\n}","preventionTips":["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."],"tags":["file-io","json","data-corruption","rust"],"backgroundTag":"account-file-unreadable","analyzedSha":"1ed8b77992d62ca81fabf744deb0839ad361d5bf","analyzedAt":"2026-09-05T09:51:41.178Z","contentChangedAt":"2026-09-05T09:51:41.178Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}