Skip to content

Truncate oversized git diffs instead of failing#1499

Merged
juliusmarminge merged 3 commits intomainfrom
t3code/large-git-diff-fix
Mar 29, 2026
Merged

Truncate oversized git diffs instead of failing#1499
juliusmarminge merged 3 commits intomainfrom
t3code/large-git-diff-fix

Conversation

@juliusmarminge
Copy link
Copy Markdown
Member

@juliusmarminge juliusmarminge commented Mar 28, 2026

Summary

  • Added truncation support to Git output collection so large diffs and patches return partial content with a clear [truncated] marker instead of failing.
  • Applied bounded output handling to checkpoint diff generation, staged commit context, and range context reads.
  • Added integration coverage for oversized checkpoint diffs and git context helpers to verify truncation behavior.

Testing

  • bun fmt
  • bun lint
  • bun typecheck
  • bun run test

Note

Medium Risk
Changes GitCore.execute behavior to optionally return truncated stdout/stderr (with a [truncated] marker) rather than erroring when output exceeds limits, which could affect downstream consumers that assume full diffs/patches.

Overview
Adds opt-in output truncation to GitCore command execution via truncateOutputAtMaxBytes, capping collected stdout/stderr and appending a \n\n[truncated] marker instead of throwing when maxOutputBytes is exceeded.

Applies per-call byte limits with truncation enabled for prepareCommitContext staged patches and readRangeContext commit/diff summaries and patches, while leaving checkpoint diffs untruncated.

Adds integration tests to verify oversized staged/range patches are truncated (and marked) and that CheckpointStore.diffCheckpoints still returns a full large diff without truncation.

Written by Cursor Bugbot for commit 1b1872c. This will update automatically on new commits. Configure here.

Note

Truncate oversized git diffs instead of failing in GitCore

  • collectOutput in GitCore.ts gains a truncateOutputAtMaxBytes option; when enabled, output is capped and suffixed with [truncated] instead of throwing a GitCommandError.
  • prepareCommitContext and readRangeContext now use per-field byte limits (49 KB for staged patches, 19–59 KB for range diff fields) with truncation enabled.
  • Integration tests in GitCore.test.ts verify that large repos produce truncated output containing [truncated] rather than errors.
  • Behavioral Change: commands that previously failed on oversized output now succeed with a truncated result; callers consuming the full diff string may now receive incomplete data.

Macroscope summarized 1b1872c.

- Add bounded output handling for staged and range git context
- Cover oversized checkpoint and commit-context diffs with tests
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 28, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 561db473-04a5-4c8f-98cb-405184df17d0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch t3code/large-git-diff-fix

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

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Mar 28, 2026
- remove checkpoint diff output truncation
- update live test to expect the full diff output
@github-actions github-actions bot added size:M 30-99 changed lines (additions + deletions). and removed size:L 100-499 changed lines (additions + deletions). labels Mar 28, 2026
@juliusmarminge juliusmarminge merged commit 9e60597 into main Mar 29, 2026
11 checks passed
@juliusmarminge juliusmarminge deleted the t3code/large-git-diff-fix branch March 29, 2026 03:50
Chrono-byte pushed a commit to Chrono-byte/t3code that referenced this pull request Mar 31, 2026
hapwi pushed a commit to hapwi/hapcode that referenced this pull request Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant