{"record":{"id":"20c2611973928511","repo":"openai/codex","slug":"no-files-were-modified","errorCode":null,"errorMessage":"No files were modified.","messagePattern":"No files were modified\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"codex-rs/apply-patch/src/lib.rs","lineNumber":483,"sourceCode":"    pub deleted: Vec<PathBuf>,\n}\n\n/// Apply the hunks to the filesystem, returning which files were added, modified, or deleted.\n/// Returns an error if the patch could not be applied.\nasync fn apply_hunks_to_files(\n    hunks: &[Hunk],\n    options: ApplyPatchOptions,\n    cwd: &PathUri,\n    fs: &dyn ExecutorFileSystem,\n    sandbox: Option<&FileSystemSandboxContext>,\n    delta: &mut AppliedPatchDelta,\n) -> anyhow::Result<AffectedPaths> {\n    let ApplyPatchOptions {\n        update_file_mode,\n        follow_symlinks,\n    } = options;\n    if hunks.is_empty() {\n        anyhow::bail!(\"No files were modified.\");\n    }\n\n    let mut added: Vec<PathBuf> = Vec::new();\n    let mut modified: Vec<PathBuf> = Vec::new();\n    let mut deleted: Vec<PathBuf> = Vec::new();\n    // A failed write can still have modified the target before surfacing an\n    // error (for example by truncating before ENOSPC), so the accumulated\n    // delta is no longer exact when a write fails.\n    macro_rules! try_write {\n        ($result:expr) => {\n            match $result {\n                Ok(value) => value,\n                Err(error) => {\n                    delta.exact = false;\n                    return Err(anyhow::Error::from(error));\n                }\n            }\n        };","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/apply-patch/src/lib.rs#L465-L501","documentation":"apply_hunks_to_files bails with this anyhow message when the hunk slice is empty (hunks.is_empty()), and it surfaces to callers wrapped in ApplyPatchFailure with an empty delta. It means the patch carried no Add/Delete/Update hunks, so the library refuses to report success for a no-op. Nothing is written to disk when this error appears.","triggerScenarios":"Calling apply_hunks/apply_hunks_with_options with an empty hunk slice, or apply_patch on patch text that parses to zero hunks - for example only '*** Begin Patch'/'*** End Patch' markers with nothing between them.","commonSituations":"Model output that emitted only the Begin/End markers; upstream filtering (dedup, path filtering) that stripped every hunk before the call; CI treating this as a hard failure when it is really a no-op.","solutions":["Treat it as a no-op, not a failure: if hunks.is_empty(), skip the apply call and return an empty delta","Log the patch text that produced zero hunks - usually only the Begin/End markers survived filtering","Check upstream hunk-filtering logic that emptied the slice"],"exampleFix":"// before\nlet delta = apply_hunks(&hunks, &cwd, &mut out, &mut err, fs, None).await?; // bails 'No files were modified.' on empty input\n\n// after\nif hunks.is_empty() {\n    return Ok(AppliedPatchDelta::default()); // no-op: nothing to apply\n}\nlet delta = apply_hunks(&hunks, &cwd, &mut out, &mut err, fs, None).await?;","handlingStrategy":"validation","validationCode":"if hunks.is_empty() {\n    return Ok(AppliedPatchDelta::default()); // treat as no-op, do not call apply_hunks\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter empty hunk lists before calling apply_hunks","Validate that model output contains at least one hunk between the Begin/End markers","Do not treat this message as filesystem damage - the delta is always empty when it appears"],"tags":["rust","apply-patch","empty-input","no-op"],"backgroundTag":"empty-patch-noop","analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}