jlcodes99/cockpit-tools · error

Codex 导入失败 {}: {}

Error message

Codex 导入失败 {}: {}

What it means

A non-disk-full failure occurred while upserting a candidate (legacy-rule) account in import_from_files. The per-account error is logged with the account label and recorded in the returned CodexFileImportFailure list; the import of remaining files continues. This message is the log line, and the label plus underlying error are surfaced to the caller.

Source

Thrown at crates/cockpit-core/src/modules/codex_account_core_mutations_quota.rs:138

            Ok(account) => {
                logger::log_info(&format!("Codex 导入成功: {}", account.email));
                imported.push(account);
            }
            Err(e) => {
                if is_disk_full_error_message(&e) {
                    logger::log_error(&format!(
                        "Codex 导入因磁盘空间不足终止: label={}, imported={}, error={}",
                        label,
                        imported.len(),
                        e
                    ));
                    return Err(format!(
                        "磁盘空间不足,已终止导入(已成功 {} 个)。{}",
                        imported.len(),
                        e
                    ));
                }
                logger::log_error(&format!("Codex 导入失败 {}: {}", label, e));
                failed.push(CodexFileImportFailure {
                    email: label,
                    error: e,
                });
            }
        }
    }

    for (content, label) in fallback_files {
        progress_index += 1;
        if let Some(app_handle) = crate::get_app_handle() {
            use tauri::Emitter;
            let _ = app_handle.emit(
                "codex:file-import-progress",
                serde_json::json!({
                    "current": progress_index,
                    "total": total,
                    "email": &label,

View on GitHub (pinned to 1ed8b77992)

Solutions

  1. Read the underlying error in CodexFileImportFailure.error for the specific account
  2. Re-authenticate that account to obtain fresh tokens and re-import
  3. Remove or update the conflicting existing account if the error indicates duplication
  4. Validate the token JSON fields (accessToken/access_token, id_token, refresh_token) before importing

Example fix

// before
{ "access_token": "expired-or-garbage" }
// after: refresh tokens first
{ "access_token": "<fresh token>", "refresh_token": "<valid refresh>", "id_token": "<valid jwt>" }
Defensive patterns

Strategy: try-catch

Try / catch

let res = import_from_files(paths).await?;
for f in &res.failures {
    // CodexFileImportFailure { email, error }
    eprintln!("account {} failed: {}", f.email, f.error);
    if f.error.contains("token") { /* re-auth this account */ }
}
// successful accounts are in res.imported regardless of failures

Prevention

When it happens

Trigger: Calling import_from_files where upsert_account_with_hints returns Err for a specific account — e.g. invalid/expired token payload, malformed id_token, duplicate email conflicting with existing account, or storage-layer write errors other than disk-full.

Common situations: Expired or revoked tokens copied from a stale auth.json; account already exists with different credentials; corrupted id_token that fails base64/JWT parsing; database locked or write permission issues.

Related errors


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