{"record":{"id":"c13ab85e2fa9d429","repo":"openai/codex","slug":"patch-detected-without-explicit-call-to-apply-patc","errorCode":null,"errorMessage":"patch detected without explicit call to apply_patch. Rerun as [\"apply_patch\", \"<patch>\"]","messagePattern":"patch detected without explicit call to apply_patch\\. Rerun as \\[\"apply_patch\", \"<patch>\"\\]","errorType":"exception","errorClass":"ApplyPatchError","httpStatus":null,"severity":"error","filePath":"codex-rs/apply-patch/src/lib.rs","lineNumber":111,"sourceCode":"        Ok(\"1\") => ApplyPatchFileUpdateMode::PreserveLineEndings,\n        _ => ApplyPatchFileUpdateMode::NormalizeToLf,\n    }\n}\n\n#[derive(Debug, Error, PartialEq)]\npub enum ApplyPatchError {\n    #[error(transparent)]\n    ParseError(#[from] ParseError),\n    #[error(transparent)]\n    IoError(#[from] IoError),\n    /// Error that occurs while computing replacements when applying patch chunks\n    #[error(\"{0}\")]\n    ComputeReplacements(String),\n    /// A patch path could not be resolved as a path URI.\n    #[error(transparent)]\n    PathUri(#[from] PathUriParseError),\n    /// A raw patch body was provided without an explicit `apply_patch` invocation.\n    #[error(\n        \"patch detected without explicit call to apply_patch. Rerun as [\\\"apply_patch\\\", \\\"<patch>\\\"]\"\n    )]\n    ImplicitInvocation,\n}\n\nimpl From<std::io::Error> for ApplyPatchError {\n    fn from(err: std::io::Error) -> Self {\n        ApplyPatchError::IoError(IoError {\n            context: \"I/O error\".to_string(),\n            source: err,\n        })\n    }\n}\n\nimpl From<&std::io::Error> for ApplyPatchError {\n    fn from(err: &std::io::Error) -> Self {\n        ApplyPatchError::IoError(IoError {\n            context: \"I/O error\".to_string(),","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/apply-patch/src/lib.rs#L93-L129","documentation":"Display format of the ApplyPatchError variant raised when a raw patch body was passed to the entry point without the expected apply_patch argv framing. The library requires the caller to invoke it as [\"apply_patch\", \"<patch>\"] so arg0 dispatch can distinguish patch mode; receiving a bare patch body trips this guard.","triggerScenarios":"Thrown at codex-rs/apply-patch/src/lib.rs:111 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Invoke the binary with argv[0] = \"apply_patch\" followed by the patch text","Route bare patches through the documented CLI wrapper instead of calling the parser directly"],"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"}