Skip to content

fix(linker): accept plain unified patches - #1021

Merged
jdx merged 2 commits into
mainfrom
codex/fix-plain-unified-patches
Jul 12, 2026
Merged

fix(linker): accept plain unified patches#1021
jdx merged 2 commits into
mainfrom
codex/fix-plain-unified-patches

Conversation

@jdx

@jdx jdx commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • accept plain unified diffs that omit diff --git headers
  • derive safe target paths from --- / +++ headers while preserving git-style parsing
  • support multi-file patches, additions, and deletions
  • retain traversal and symlink protections for header-derived paths

Root cause

The patch splitter only populated each section's target path from a diff --git line. Plain diff -u patches were parsed into a body with no path and failed with patch section missing file path, even though pnpm accepts them.

Reported in Discussion #1018.

Validation

  • cargo fmt --check
  • cargo test -p aube-linker patches::tests
  • cargo clippy -p aube-linker --all-targets -- -D warnings
  • reporter's end-to-end reproduction against the debug aube binary

Note

Medium Risk
Changes patch parsing and file-boundary logic on the install/link path; mistakes could mis-apply patches or split files wrong, though existing path-escape and symlink guards still apply.

Overview
Fixes patch application when users supply plain diff -u output (no diff --git lines), which previously failed because each section never got a target path.

split_patch_sections now splits on either git boundaries or unified-diff file headers: paths come from --- / +++ via unified_header_path (including bare paths and timestamp suffixes), and hunk line counts distinguish the next file’s --- from hunk content— including multi-hunk and multi-file plain patches, adds (--- /dev/null), and deletes (+++ /dev/null). Git-style parsing is unchanged. Empty-parse errors now say “no parseable file sections.”

Adds tests for plain unified apply paths, traversal rejection, and zero-count hunks at file boundaries.

Reviewed by Cursor Bugbot for commit f7bfe8b. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Jul 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@jdx, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Central YAML (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro Plus

Run ID: 271160f6-e13a-45b1-8b7d-58110d326405

📥 Commits

Reviewing files that changed from the base of the PR and between 06601ee and f7bfe8b.

📒 Files selected for processing (1)
  • crates/aube-linker/src/patches.rs

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@jdx
jdx marked this pull request as ready for review July 12, 2026 00:23

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 9581220. Configure here.

Comment thread crates/aube-linker/src/patches.rs Outdated
@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR teaches split_patch_sections to recognise plain diff -u patches (no diff --git header) in addition to git-style ones. It does so by tracking per-hunk line counts so that a --- prefix can be correctly identified as a new file boundary rather than a deletion hunk line after the previous hunk's counter reaches zero.

  • Two new helpers are introduced: unified_header_path strips a//b/ prefixes and tab-separated timestamps to derive a safe relative path, and hunk_line_counts parses @@ -<n>[,<c>] +<n>[,<c>] @@ headers into (old_count, new_count) tuples.
  • The existing diff --git code path is fully preserved; hunk_remaining is reset whenever a diff --git line is seen, so git-style parsing is unchanged.
  • Six new tests cover single-file, multi-hunk, multi-file, add/delete, zero-count-hunk, and path-escape cases; all traversal and symlink protections are exercised by the existing guards in apply_multi_file_patch.

Confidence Score: 5/5

Safe to merge — the plain-patch path shares all existing traversal and symlink guards, git-style parsing is unchanged, and the new hunk-count boundary detection is well-tested.

The hunk-counter logic correctly distinguishes --- file headers from deletion hunk lines by tracking remaining old/new line counts per hunk. Zero-count hunks immediately clear the counter so the following --- is correctly treated as a boundary. Path derivation falls back to bare paths after stripping prefixes and timestamps. All security-sensitive operations are reached identically for both git-style and plain patches.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube-linker/src/patches.rs Adds hunk-count tracking and two helper functions to accept plain unified diffs alongside git-style patches; git-style path and all security guards (path traversal, symlink) are unchanged

Reviews (2): Last reviewed commit: "fix(linker): handle unified patch edge c..." | Re-trigger Greptile

Comment thread crates/aube-linker/src/patches.rs
Comment thread crates/aube-linker/src/patches.rs
@jdx
jdx merged commit 5c0041c into main Jul 12, 2026
18 checks passed
@jdx
jdx deleted the codex/fix-plain-unified-patches branch July 12, 2026 14:03
@cursor cursor Bot mentioned this pull request Jul 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant