Hmbown/CodeWhale · error · anyhow::Error
only *** Update File patches are supported
Error message
only *** Update File patches are supported
What it means
apply_patch supports only the `*** Update File:` directive in the line after the header. If the second line is anything else (e.g. `*** Add File:`, `*** Delete File:`), strip_prefix fails and this error is returned. The eval harness implements a minimal patch subset.
Solutions
- Rewrite the patch to use `*** Update File: <workspace-relative-path>` only.
- For new files, pre-create an empty file in the workspace and then patch it, or apply changes outside this eval harness.
- Check for exact spelling and the `*** Update File: ` prefix including trailing space.
Example fix
// before *** Add File: src/new.rs // after (file must already exist) *** Update File: src/new.rs
Defensive patterns
Strategy: validation
Validate before calling
let header = patch.lines().nth(1).unwrap_or_default();
if !header.starts_with("*** Update File: ") {
eprintln!("only Update File patches supported; got: {header}");
return;
} Type guard
fn is_update_file_patch(s: &str) -> bool {
s.lines().nth(1).map_or(false, |h| h.starts_with("*** Update File: "))
} Try / catch
match apply_patch(&root, patch) {
Err(e) if e.to_string().contains("only *** Update File") => {
eprintln!("convert Add/Delete File operations to Update File against an existing file");
}
other => other?,
} Prevention
- Pre-create target files so patches only need Update File.
- Constrain model prompts to Update-File-only patches.
- Validate patch directives before submission.
When it happens
Trigger: A patch whose header line is not `*** Update File: <path>` — Add File / Delete File directives, or a malformed header like `***Update File:`.
Common situations: Model tries to create a new file via `*** Add File:`; header misspelled or missing the trailing colon+space; patch dialect from a different tool version.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- patch missing *** Begin Patch header
- unexpected patch directive
- patch context not found in
- unsupported patch line
- active provider has no native web-search adapter
AI-assisted analysis of Hmbown/CodeWhale@73e0f67d83 (2026-09-22).
Data as JSON: /api/errors/4eca5e825fdaa0c2.
Report an issue: GitHub.
Appendix: source
Thrown at crates/tui/src/eval.rs:688
content.push('\n');
}
content.push_str(line);
content.push('\n');
fs::write(path, content).with_context(|| format!("failed to write {}", path.display()))
}
fn apply_patch(root: &Path, patch: &str) -> Result<()> {
let mut lines = patch.lines();
let begin = lines.next().unwrap_or_default();
if begin != "*** Begin Patch" {
return Err(anyhow!("patch missing *** Begin Patch header"));
}
let header = lines.next().unwrap_or_default();
let file_rel = header
.strip_prefix("*** Update File: ")
.ok_or_else(|| anyhow!("only *** Update File patches are supported"))?;
if file_rel.contains("..") {
return Err(anyhow!("patch path must be workspace-relative"));
}
let file_path = root.join(file_rel);
let original = read_workspace_file(&file_path)?;
let had_trailing_newline = original.ends_with('\n');
let mut file_lines: Vec<String> = original.lines().map(|l| l.to_string()).collect();
let mut cursor = 0usize;
for raw_line in lines {
if raw_line == "*** End Patch" {
break;
}
if raw_line.starts_with("*** ") {
return Err(anyhow!("unexpected patch directive: {raw_line}"));
}
if raw_line.starts_with("@@") {View on GitHub (pinned to 73e0f67d83)