Skip to content

fix(git): gate git-lfs auto-install on provisioned hosts, matching ensureGit - #828

Merged
skevetter merged 4 commits into
mainfrom
fix/lfs-no-autoinstall
Jul 31, 2026
Merged

fix(git): gate git-lfs auto-install on provisioned hosts, matching ensureGit#828
skevetter merged 4 commits into
mainfrom
fix/lfs-no-autoinstall

Conversation

@skevetter

@skevetter skevetter commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Plain git never installs missing tools on your behalf — when the filter=lfs driver isn't configured/available, it silently leaves LFS-tracked files as pointer stubs. SetupLFS diverged from that by unconditionally trying to apt/GitHub-release install git-lfs on every clone that uses it.
  • In unprivileged/local environments (no root, no write access to /usr/local/bin) that install attempt always fails, wasting a network round trip and logging permission-denied errors that look like real failures even though the fallback works fine.
  • SetupLFS now takes an allowInstall bool. When git-lfs is missing: allowInstall=false falls back straight to pointer stubs (no install attempt, matching plain git's own default); allowInstall=true attempts the install (via the reinstated InstallLFS) and still falls back gracefully if that fails.
  • pkg/agent's getGitOptions sets allowInstall to !isLocalAgent(agentConfig) — the same agentConfig.Local check ensureGit already uses to decide whether to auto-install the git binary itself. So: a user's local machine never gets an auto-install attempt (matches ensureGit refusing to install git locally too); a devsy-provisioned remote/cloud host — where devsy already has install rights — gets the same auto-install behavior for git-lfs that it gets for git.
  • --git-lfs-mode still defaults to full and is unchanged; this only affects what happens when the git-lfs binary isn't found.
  • Tests: TestSetupLFSSkipsWhenBinaryMissingAndInstallNotAllowed, TestSetupLFSInstallsWhenBinaryMissingAndInstallAllowed (both stub lfsInstaller to avoid a real network call), TestIsLocalAgent.

Plain git never installs missing tools on your behalf: with no LFS
filter available it just leaves pointer stubs, silently. SetupLFS
diverged from that by trying to apt/GitHub-release install git-lfs on
every clone, which only ever fails in unprivileged environments and
adds noisy permission-denied logs plus a wasted network round trip.
Drop the install attempt so devsy matches git's own default behavior:
use git-lfs when it's already present, fall back to pointer stubs
when it's not.
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

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

@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Git and Git LFS installation behavior is now controlled by agent locality. Local agents avoid installation, while remote agents retain Git installation and permit LFS installation during cloning.

Changes

Local Agent Git and LFS Installation Control

Layer / File(s) Summary
LFS installation control
pkg/git/clone.go, pkg/git/lfs.go, pkg/git/lfs_test.go
Clone options control LFS installation, and SetupLFS handles missing binaries through an injectable installer with coverage for allowed, disallowed, and failed installation.
Clone-to-repository LFS propagation
pkg/git/repo.go
Repository cloning passes the configured LFS installation permission to SetupLFS.
Local-agent installation policy
pkg/agent/workspace.go, pkg/agent/workspace_test.go
Local-agent detection prevents Git installation and configures Git clone options to disallow LFS installation; detection is tested for true, false, and unset values.

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

Sequence Diagram(s)

sequenceDiagram
  participant Workspace
  participant GitClone
  participant Repo
  participant LFS
  Workspace->>GitClone: build options from agent configuration
  GitClone->>Repo: clone with allowLFSInstall
  Repo->>LFS: SetupLFS(mode, allowLFSInstall)
  LFS-->>Repo: skip or perform git-lfs installation
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: gating automatic Git LFS installation based on host provisioning, consistent with existing Git handling.

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.

@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

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

Reinstate git-lfs auto-install, but only where devsy.ensureGit already
draws the same line for the git binary itself: devsy-provisioned remote
hosts it controls, never a user's local environment. Adds
WithAllowLFSInstall/SetupLFS(..., allowInstall) so the decision is made
once at the call site (mirroring ensureGit's isLocalAgent check) instead
of unconditionally inside SetupLFS, which is what caused every clone in
an unprivileged host to fail apt/GitHub-release installs and log
permission-denied noise.
@github-actions github-actions Bot added size/m and removed size/s labels Jul 31, 2026
SetupLFS's cyclomatic complexity hit 9 (max 8) after the allowInstall
branch. Split the missing-binary handling into its own function.
@skevetter
skevetter marked this pull request as ready for review July 31, 2026 01:29

@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: 1

🤖 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 `@pkg/git/lfs.go`:
- Around line 56-57: Remove the automatic Git LFS installation path: in
pkg/git/lfs.go:56-57, log and return when binGitLFS is absent, and remove
lfsInstaller and ensureLFSBinary; in pkg/git/clone.go:110-121, remove
WithAllowLFSInstall and allowLFSInstall; in pkg/git/repo.go:176, stop
propagating the installation flag; in pkg/agent/workspace.go:480, stop enabling
LFS installation for remote agents; and in pkg/git/lfs_test.go:120-138, replace
the installation-allowed test with coverage confirming the installer is never
invoked when git-lfs is missing.
🪄 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: 686aea2f-7529-4b62-830f-b87ecc2e5ea2

📥 Commits

Reviewing files that changed from the base of the PR and between b05a582 and 7121041.

📒 Files selected for processing (6)
  • pkg/agent/workspace.go
  • pkg/agent/workspace_test.go
  • pkg/git/clone.go
  • pkg/git/lfs.go
  • pkg/git/lfs_test.go
  • pkg/git/repo.go

Comment thread pkg/git/lfs.go
Comment on lines +56 to +57
if !command.Exists(binGitLFS) && !ensureLFSBinary(ctx, allowInstall) {
return

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Remove the remaining automatic Git LFS installation path.

The PR objective says missing git-lfs must fall back to pointer stubs without installation, but non-local agents still call InstallLFS through lfsInstaller.

  • pkg/git/lfs.go#L56-L57: log and return when git-lfs is absent; remove lfsInstaller and ensureLFSBinary.
  • pkg/git/clone.go#L110-L121: remove WithAllowLFSInstall and allowLFSInstall.
  • pkg/git/repo.go#L176-L176: remove propagation of the installation flag.
  • pkg/agent/workspace.go#L480-L480: stop enabling LFS installation for remote agents.
  • pkg/git/lfs_test.go#L120-L138: replace the “installation allowed” test with coverage that the installer is never invoked when the binary is missing.
📍 Affects 5 files
  • pkg/git/lfs.go#L56-L57 (this comment)
  • pkg/git/clone.go#L110-L121
  • pkg/git/repo.go#L176-L176
  • pkg/agent/workspace.go#L480-L480
  • pkg/git/lfs_test.go#L120-L138
🤖 Prompt for 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.

In `@pkg/git/lfs.go` around lines 56 - 57, Remove the automatic Git LFS
installation path: in pkg/git/lfs.go:56-57, log and return when binGitLFS is
absent, and remove lfsInstaller and ensureLFSBinary; in
pkg/git/clone.go:110-121, remove WithAllowLFSInstall and allowLFSInstall; in
pkg/git/repo.go:176, stop propagating the installation flag; in
pkg/agent/workspace.go:480, stop enabling LFS installation for remote agents;
and in pkg/git/lfs_test.go:120-138, replace the installation-allowed test with
coverage confirming the installer is never invoked when git-lfs is missing.

@skevetter skevetter changed the title fix(git): stop auto-installing git-lfs, match native git defaults fix(git): gate git-lfs auto-install on provisioned hosts, matching ensureGit Jul 31, 2026
@skevetter
skevetter merged commit 7d259bc into main Jul 31, 2026
66 checks passed
@skevetter
skevetter deleted the fix/lfs-no-autoinstall branch July 31, 2026 01:34
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