{"record":{"id":"4eca5e825fdaa0c2","repo":"Hmbown/CodeWhale","slug":"only-update-file-patches-are-supported","errorCode":null,"errorMessage":"only *** Update File patches are supported","messagePattern":"only \\*\\*\\* Update File patches are supported","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/tui/src/eval.rs","lineNumber":688,"sourceCode":"        content.push('\\n');\n    }\n    content.push_str(line);\n    content.push('\\n');\n    fs::write(path, content).with_context(|| format!(\"failed to write {}\", path.display()))\n}\n\nfn apply_patch(root: &Path, patch: &str) -> Result<()> {\n    let mut lines = patch.lines();\n\n    let begin = lines.next().unwrap_or_default();\n    if begin != \"*** Begin Patch\" {\n        return Err(anyhow!(\"patch missing *** Begin Patch header\"));\n    }\n\n    let header = lines.next().unwrap_or_default();\n    let file_rel = header\n        .strip_prefix(\"*** Update File: \")\n        .ok_or_else(|| anyhow!(\"only *** Update File patches are supported\"))?;\n    if file_rel.contains(\"..\") {\n        return Err(anyhow!(\"patch path must be workspace-relative\"));\n    }\n\n    let file_path = root.join(file_rel);\n    let original = read_workspace_file(&file_path)?;\n    let had_trailing_newline = original.ends_with('\\n');\n    let mut file_lines: Vec<String> = original.lines().map(|l| l.to_string()).collect();\n\n    let mut cursor = 0usize;\n    for raw_line in lines {\n        if raw_line == \"*** End Patch\" {\n            break;\n        }\n        if raw_line.starts_with(\"*** \") {\n            return Err(anyhow!(\"unexpected patch directive: {raw_line}\"));\n        }\n        if raw_line.starts_with(\"@@\") {","sourceCodeStart":670,"sourceCodeEnd":706,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/eval.rs#L670-L706","documentation":"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.","triggerScenarios":"A patch whose header line is not `*** Update File: <path>` — Add File / Delete File directives, or a malformed header like `***Update File:`.","commonSituations":"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.","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."],"exampleFix":"// before\n*** Add File: src/new.rs\n// after (file must already exist)\n*** Update File: src/new.rs","handlingStrategy":"validation","validationCode":"let header = patch.lines().nth(1).unwrap_or_default();\nif !header.starts_with(\"*** Update File: \") {\n    eprintln!(\"only Update File patches supported; got: {header}\");\n    return;\n}","typeGuard":"fn is_update_file_patch(s: &str) -> bool {\n    s.lines().nth(1).map_or(false, |h| h.starts_with(\"*** Update File: \"))\n}","tryCatchPattern":"match apply_patch(&root, patch) {\n    Err(e) if e.to_string().contains(\"only *** Update File\") => {\n        eprintln!(\"convert Add/Delete File operations to Update File against an existing file\");\n    }\n    other => other?,\n}","preventionTips":["Pre-create target files so patches only need Update File.","Constrain model prompts to Update-File-only patches.","Validate patch directives before submission."],"tags":["patch","parsing","eval","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}