Skip to content

fix(git): disable LFS filter driver during clone when git-lfs binary is missing - #813

Open
skevetter wants to merge 3 commits into
mainfrom
stupid-parrot
Open

fix(git): disable LFS filter driver during clone when git-lfs binary is missing#813
skevetter wants to merge 3 commits into
mainfrom
stupid-parrot

Conversation

@skevetter

@skevetter skevetter commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

  • GIT_LFS_SKIP_SMUDGE is only consulted by the git-lfs binary itself, so setting it did nothing when that binary wasn't installed: git still tried to exec the missing filter driver during checkout and failed outright (Clone succeeded, but checkout failed). Clone now overrides filter.lfs.process/smudge/clean to no-ops when git-lfs isn't on PATH, so checkout falls back to pointer stubs instead of failing.
  • removeGitCredentialHelper no longer errors when a failed clone already removed the workspace dir (the .git/config it tries to clean up no longer exists).
  • Added e2e/tests/up/git_lfs_test.go, a real-git integration test (no mocks/docker) that reproduces the exact production failure with git-lfs hidden from PATH and verifies the fix.

Summary by CodeRabbit

  • Bug Fixes

    • Improved cloning of repositories containing Git LFS files when the Git LFS binary is unavailable.
    • Prevented unnecessary Git credential-helper cleanup when the local configuration is missing.
    • Clone behavior now correctly adapts based on whether Git LFS is installed.
  • Tests

    • Added coverage for Git LFS cloning without the Git LFS executable.
    • Added validation for clone behavior with and without Git LFS support.

…is missing

GIT_LFS_SKIP_SMUDGE is only consulted by the git-lfs binary itself, so
setting it did nothing when the binary wasn't installed: git still tried
to exec the missing filter driver during checkout and failed outright.
Override filter.lfs.process/smudge/clean instead so checkout falls back
to pointer stubs. Also stop removeGitCredentialHelper from erroring when
a failed clone already removed the workspace dir.
@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

Name Link
🔨 Latest commit da68e0b
🔍 Latest deploy log https://app.netlify.com/projects/images-devsy-sh/deploys/6a6ad023620f310008edd20b

@netlify

netlify Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit da68e0b
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a6ad023bc3e540008b977dd

@coderabbitai

coderabbitai Bot commented Jul 30, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 9 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 1f3612be-7d1d-48d6-8f26-2da5a38d52bc

📥 Commits

Reviewing files that changed from the base of the PR and between 1e0ce24 and da68e0b.

📒 Files selected for processing (2)
  • e2e/tests/up/git_lfs_test.go
  • pkg/agent/workspace.go
📝 Walkthrough

Walkthrough

Changes

Git LFS clone handling

Layer / File(s) Summary
LFS clone policy and tests
pkg/git/lfs.go, pkg/git/lfs_test.go
Clone setup uses GIT_LFS_SKIP_SMUDGE=1 when git-lfs exists and disables LFS filters when it does not, with corresponding tests.
Clone wiring and end-to-end validation
pkg/git/repo.go, e2e/tests/up/git_lfs_test.go
cloneWith applies the selected LFS arguments and environment; the e2e test verifies cloning succeeds without the git-lfs binary.

Git credential cleanup

Layer / File(s) Summary
Guard credential-helper cleanup
pkg/agent/workspace.go
Credential-helper removal now stops when the local Git configuration path cannot be found.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant cloneWith
  participant LFSHelpers
  participant Git
  participant git-lfs
  cloneWith->>LFSHelpers: select clone args and environment
  cloneWith->>Git: execute clone
  alt git-lfs available
    Git->>git-lfs: apply LFS filters with smudge skipped
  else git-lfs unavailable
    Git->>Git: use disabled LFS filter commands
  end
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: disabling the LFS filter driver during clone when git-lfs is missing.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

Split the integration test into focused helpers to reduce cyclomatic
complexity, wrap long lines, and annotate the test-owned file read.
@skevetter
skevetter marked this pull request as ready for review July 30, 2026 03:26

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@e2e/tests/up/git_lfs_test.go`:
- Around line 52-56: Update the PATH setup in the test helper to keep cat
available alongside git: resolve the system cat binary, symlink it into binDir,
and fail the test if that symlink cannot be created. Preserve the existing
restricted PATH and git symlink behavior so the test still exercises the
missing-git-lfs fallback.

In `@pkg/agent/workspace.go`:
- Around line 301-304: Update the os.Stat guard in the workspace cleanup flow to
ignore only errors matching os.ErrNotExist; for other failures, log the error
before returning. Preserve the existing early return when gitConfigPath is
absent and keep credential-helper cleanup unchanged when stat succeeds.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 7716a6f0-171e-4cb7-b94f-6cb3a38c3a43

📥 Commits

Reviewing files that changed from the base of the PR and between 0f1fb59 and 1e0ce24.

📒 Files selected for processing (5)
  • e2e/tests/up/git_lfs_test.go
  • pkg/agent/workspace.go
  • pkg/git/lfs.go
  • pkg/git/lfs_test.go
  • pkg/git/repo.go

Comment thread e2e/tests/up/git_lfs_test.go
Comment thread pkg/agent/workspace.go
- Only ignore os.ErrNotExist when skipping credential-helper cleanup;
  log other stat failures instead of swallowing them.
- Keep "cat" reachable in the e2e test's restricted PATH so it
  exercises the clone's filter.lfs.smudge=cat override directly,
  rather than passing via git's fallback for an unresolvable filter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant