{"record":{"id":"4dba747b728f7329","repo":"openai/codex","slug":"refusing-to-reuse-existing-mismatched-file","errorCode":null,"errorMessage":"refusing to reuse existing mismatched file {}","messagePattern":"refusing to reuse existing mismatched file (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/network-proxy/src/certs.rs","lineNumber":772,"sourceCode":"}\n\n#[cfg(windows)]\nfn sync_parent_dir(_parent: &Path) -> Result<()> {\n    Ok(())\n}\n\nfn write_atomic_create_new_or_reuse(path: &Path, contents: &[u8], mode: u32) -> Result<()> {\n    if fs::symlink_metadata(path)\n        .ok()\n        .is_some_and(|metadata| metadata.file_type().is_symlink())\n    {\n        return Err(anyhow!(\"refusing to reuse symlink {}\", path.display()));\n    }\n    if fs::read(path).ok().as_deref() == Some(contents) {\n        return Ok(());\n    }\n    if path.exists() {\n        return Err(anyhow!(\n            \"refusing to reuse existing mismatched file {}\",\n            path.display()\n        ));\n    }\n    match write_atomic_create_new(path, contents, mode) {\n        Ok(()) => Ok(()),\n        Err(_err) if fs::read(path).ok().as_deref() == Some(contents) => Ok(()),\n        Err(err) => Err(err),\n    }\n}\n\n#[cfg(unix)]\nfn open_create_new_with_mode(path: &Path, mode: u32) -> Result<File> {\n    use std::os::unix::fs::OpenOptionsExt;\n\n    OpenOptions::new()\n        .write(true)\n        .create_new(true)","sourceCodeStart":754,"sourceCodeEnd":790,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/network-proxy/src/certs.rs#L754-L790","documentation":"write_atomic_create_new_or_reuse found an existing regular file at the destination whose bytes differ from the intended contents. Rather than overwrite a mismatched artifact (possibly from another CA generation or tampering), the write refuses.","triggerScenarios":"Thrown at codex-rs/network-proxy/src/certs.rs:772 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Delete the mismatched artifact and retry so it is written fresh","If stale CA artifacts accumulated, prune old managed CA certificates","Confirm no other codex version or process is writing different contents concurrently"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}