BigPizzaV3/CodexPlusPlus · error

待处理的一键换肤记录无效

Error message

待处理的一键换肤记录无效

What it means

load_pending_community_link reads the pending one-click skin-link record file and bails if the file is not a small (<= 4096 bytes) regular file. Symlinks, directories, or oversized files indicate a corrupted or malicious pending record, so it is rejected instead of parsed. Note: the record also must contain a valid versionId or a separate error fires.

Solutions

  1. Delete the invalid pending-record file so the next load returns Ok(None) and a fresh record can be written.
  2. Re-run the one-click link flow to recreate the pending record.
  3. Check for processes concurrently writing to the state dir and serialize state-dir access.
  4. Inspect the file's symlink_metadata to confirm it is a small regular file before debugging further.

Example fix

// before
let pending = load_pending_community_link(state_dir)?;
// after
let pending = match load_pending_community_link(state_dir) {
    Ok(p) => p,
    Err(_) => { let _ = std::fs::remove_file(pending_path(state_dir)); None }
};
Defensive patterns

Strategy: try-catch

Validate before calling

// Rust
let md = std::fs::symlink_metadata(&path)?;
let ok = md.is_file() && md.len() <= 4096;

Try / catch

// Rust
let pending = load_pending_community_link(state_dir).unwrap_or(None); // treat invalid record as absent and recreate it

Prevention

When it happens

Trigger: Calling load_pending_community_link when the pending-record file at state_dir is: a symlink, a directory, a special file, or larger than 4096 bytes.

Common situations: Another process wrote garbage or logs into the pending file; a user replaced the file with a symlink during state-dir sharing; disk corruption or interrupted write left an oversized partial file.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: source

Thrown at crates/codex-plus-core/src/dream_skin_community.rs:242

fn version_id_from_link(url: &str) -> anyhow::Result<String> {
    let version_id = url
        .strip_prefix("dreamskin://apply?version=")
        .or_else(|| url.strip_prefix("dreamskin://apply/?version="))
        .context("一键换肤链接无效")?;
    validate_version_id(version_id)?;
    Ok(version_id.to_string())
}

pub fn load_pending_community_link() -> anyhow::Result<Option<String>> {
    let path = pending_link_path();
    if !path.exists() {
        return Ok(None);
    }
    let metadata = std::fs::symlink_metadata(&path)?;
    if !metadata.file_type().is_file() || metadata.file_type().is_symlink() || metadata.len() > 4096
    {
        bail!("待处理的一键换肤记录无效");
    }
    let value: serde_json::Value = serde_json::from_slice(&std::fs::read(path)?)?;
    let version_id = value
        .get("versionId")
        .and_then(serde_json::Value::as_str)
        .context("待处理的一键换肤记录缺少版本 ID")?
        .to_string();
    validate_version_id(&version_id)?;
    Ok(Some(version_id))
}

pub fn clear_pending_community_link() -> anyhow::Result<()> {
    let path = pending_link_path();
    match std::fs::remove_file(path) {
        Ok(()) => Ok(()),
        Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(()),
        Err(error) => Err(error.into()),
    }

View on GitHub (pinned to b1ed92e5e4)