{"record":{"id":"79b1a6e43bd6be52","repo":"Hmbown/CodeWhale","slug":"unsupported-patch-line-raw-line","errorCode":null,"errorMessage":"unsupported patch line: {raw_line}","messagePattern":"unsupported patch line: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/tui/src/eval.rs","lineNumber":742,"sourceCode":"                    ));\n                };\n                cursor = found + 1;\n            }\n            \"-\" => {\n                if cursor >= file_lines.len() || file_lines[cursor] != content {\n                    return Err(anyhow!(\n                        \"patch removal mismatch in {}: expected '{}'\",\n                        file_path.display(),\n                        content\n                    ));\n                }\n                file_lines.remove(cursor);\n            }\n            \"+\" => {\n                file_lines.insert(cursor, content);\n                cursor += 1;\n            }\n            _ => return Err(anyhow!(\"unsupported patch line: {raw_line}\")),\n        }\n    }\n\n    let mut updated = file_lines.join(\"\\n\");\n    if had_trailing_newline {\n        updated.push('\\n');\n    }\n\n    fs::write(&file_path, updated)\n        .with_context(|| format!(\"failed to write patched file {}\", file_path.display()))\n}\n\nfn run_bash(root: &Path, command: &str) -> Result<String> {\n    crate::shell_dispatcher::global_dispatcher().run_foreground(command, root)\n}\n\nfn truncate_output(value: &str, max_chars: usize) -> String {\n    if value.chars().count() <= max_chars {","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/tui/src/eval.rs#L724-L760","documentation":"The eval patch applier's line parser recognizes only a fixed set of line prefixes ('-', '+', and context lines matched earlier in the match). Any other raw line terminates the loop with this error, guarding against malformed or truncated patches being silently misapplied.","triggerScenarios":"Calling the patch applier with a patch containing a line whose first token is not a supported opcode — e.g. a diff header (---, +++, diff --git), an @@ hunk header, or garbage output from the model that got past prefix stripping.","commonSituations":"The model emitted a full unified diff (with @@ hunks and ---/+++ headers) instead of the simplified patch format this applier expects; a truncated patch line lost its leading marker; leading whitespace shifted the opcode character.","solutions":["Inspect the failing line (`raw_line`) and strip or pre-process unsupported headers (---, +++, @@) before feeding the patch to the applier.","Fix the patch generator/prompt so it emits only the simplified '-'/'+ '/context line format.","Check that the patch wasn't truncated or mangled (missing leading '-'/'+' on a line)."],"exampleFix":"// before: full unified diff fed directly\n@@ -1,3 +1,3 @@\n// after: pre-strip headers before applying\nlet body: Vec<&str> = raw.lines().filter(|l| !l.starts_with(\"@@\") && !l.starts_with(\"---\") && !l.starts_with(\"+++\"))...","handlingStrategy":"validation","validationCode":"fn is_supported_patch(lines: &[&str]) -> bool {\n    lines.iter().all(|l| {\n        l.is_empty() || l.starts_with('-') || l.starts_with('+') || l.starts_with(' ')\n    })\n}","typeGuard":null,"tryCatchPattern":"match apply_patch(path, &patch) {\n    Err(e) if e.to_string().contains(\"unsupported patch line\") => {\n        eprintln!(\"malformed patch, skipping: {e}\");\n        // fall back to full-file rewrite or re-request from the model\n    }\n    other => other?,\n}","preventionTips":["Strip unified-diff headers (---, +++, @@) before handing a patch to the applier.","Prompt/validate the generator to emit only the simplified +/-/context format.","Check patch integrity (no truncated lines) before application."],"tags":["patch","parsing","unsupported-input","rust"],"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"}