openai/codex · warning
No files were modified.
Error message
No files were modified.
What it means
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.
Source
Thrown at codex-rs/apply-patch/src/lib.rs:483
pub deleted: Vec<PathBuf>,
}
/// Apply the hunks to the filesystem, returning which files were added, modified, or deleted.
/// Returns an error if the patch could not be applied.
async fn apply_hunks_to_files(
hunks: &[Hunk],
options: ApplyPatchOptions,
cwd: &PathUri,
fs: &dyn ExecutorFileSystem,
sandbox: Option<&FileSystemSandboxContext>,
delta: &mut AppliedPatchDelta,
) -> anyhow::Result<AffectedPaths> {
let ApplyPatchOptions {
update_file_mode,
follow_symlinks,
} = options;
if hunks.is_empty() {
anyhow::bail!("No files were modified.");
}
let mut added: Vec<PathBuf> = Vec::new();
let mut modified: Vec<PathBuf> = Vec::new();
let mut deleted: Vec<PathBuf> = Vec::new();
// A failed write can still have modified the target before surfacing an
// error (for example by truncating before ENOSPC), so the accumulated
// delta is no longer exact when a write fails.
macro_rules! try_write {
($result:expr) => {
match $result {
Ok(value) => value,
Err(error) => {
delta.exact = false;
return Err(anyhow::Error::from(error));
}
}
};View on GitHub (pinned to 339751715c)
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
Example fix
// before
let delta = apply_hunks(&hunks, &cwd, &mut out, &mut err, fs, None).await?; // bails 'No files were modified.' on empty input
// after
if hunks.is_empty() {
return Ok(AppliedPatchDelta::default()); // no-op: nothing to apply
}
let delta = apply_hunks(&hunks, &cwd, &mut out, &mut err, fs, None).await?; Defensive patterns
Strategy: validation
Validate before calling
if hunks.is_empty() {
return Ok(AppliedPatchDelta::default()); // treat as no-op, do not call apply_hunks
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- {error}
- InvalidInput
- invalid patch: {0}
- invalid hunk at line {line_number}, {message}
- queries must not be empty or contain empty strings
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/20c2611973928511.
Report an issue: GitHub.