BigPizzaV3/CodexPlusPlus · error · anyhow::Error

未知配置文件类型:

Error message

未知配置文件类型:{other}

What it means

A write-config helper accepts only the literal kinds "config" (writes config.toml) and "auth" (writes auth.json) inside the codex home. Any other kind string hits the catch-all match arm and bails with the unsupported type name interpolated into the message.

Solutions

  1. Pass exactly "config" to write config.toml or "auth" to write auth.json
  2. Fix typos/normalization at the call site (trim + lowercase, strip extensions)
  3. If a new file kind is genuinely needed, add a match arm for it in the helper

Example fix

// before
write_config_file("config.toml", contents);
// after
write_config_file("config", contents);
Defensive patterns

Strategy: validation

Validate before calling

const KINDS = ['config', 'auth']; if (!KINDS.includes(kind)) throw new Error(`kind must be config or auth, got ${kind}`);

Type guard

const isConfigKind = (k: string): k is 'config' | 'auth' => k === 'config' || k === 'auth';

Try / catch

try { await writeConfigFile(kind, contents) } catch (e) { if (String(e).includes('未知配置文件类型')) console.error('bad kind:', kind); }

Prevention

When it happens

Trigger: Invoking the config-writing command (commands.rs ~5821) with kind set to anything other than "config" or "auth", e.g. a typo like "config.toml", "settings", or a lowercased/uppercased variant.

Common situations: Test helper or IPC caller passes a wrong kind string; a refactor renamed kinds without updating call sites; dynamic kind computed from user input or a file extension.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19). Data as JSON: /api/errors/70ba9f7371b68fa7. Report an issue: GitHub.

Appendix: source

Thrown at apps/codex-plus-manager/src-tauri/src/commands.rs:5821

    let config_path = home.join("config.toml");
    let auth_path = home.join("auth.json");
    Ok(RelayFilesPayload {
        config_path: config_path.to_string_lossy().to_string(),
        auth_path: auth_path.to_string_lossy().to_string(),
        config_contents: read_optional_text_file(&config_path)?,
        auth_contents: read_optional_text_file(&auth_path)?,
    })
}

fn save_relay_file_in_home(
    home: &std::path::Path,
    kind: &str,
    contents: &str,
) -> anyhow::Result<()> {
    let path = match kind {
        "config" => home.join("config.toml"),
        "auth" => home.join("auth.json"),
        other => anyhow::bail!("未知配置文件类型:{other}"),
    };
    if let Some(parent) = path.parent() {
        std::fs::create_dir_all(parent)?;
    }
    std::fs::write(path, contents)?;
    Ok(())
}

fn prepare_relay_file_contents(
    kind: &str,
    contents: &str,
    profile: &RelayProfile,
) -> anyhow::Result<String> {
    if kind == "config" {
        return codex_plus_core::relay_config::apply_deepseek_responses_compatibility(
            profile, contents,
        );
    }

View on GitHub (pinned to b1ed92e5e4)