Skip to content

fix(git): check write/root capability before installing git-lfs - #831

Merged
skevetter merged 3 commits into
mainfrom
fix/lfs-install-privilege-check
Jul 31, 2026
Merged

fix(git): check write/root capability before installing git-lfs#831
skevetter merged 3 commits into
mainfrom
fix/lfs-install-privilege-check

Conversation

@skevetter

@skevetter skevetter commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • fix(git): gate git-lfs auto-install on provisioned hosts, matching ensureGit #828 gated git-lfs auto-install on `isLocalAgent(agentConfig)` (mirroring `ensureGit`'s existing rule for the `git` binary), so it only attempts install on non-local/devsy-provisioned hosts. That assumption doesn't hold universally: a remote/SSH machine provider (e.g. `ws3-ssh`) is "non-local" but not necessarily privileged — confirmed in production logs where a beta build containing fix(git): gate git-lfs auto-install on provisioned hosts, matching ensureGit #828 still hit the exact same `apt`/`github-release` permission-denied noise as before, because the remote user account there isn't root.
  • `pkgManagerStrategy.usable()` now also requires `isRoot()` (overridable in tests) — apt/apk installs write to root-owned locations regardless of host type, so this is a direct capability check rather than a provider-type proxy.
  • The release strategy (`releaseSource.install`) now calls `ensureDirWritable` on the resolved install dir before downloading anything, so a doomed install never wastes a network round trip.
  • Net effect: git-lfs auto-install is attempted only where it can plausibly succeed, regardless of whether the host is "local," "non-local," or any other provider-type label — fixing the gap in fix(git): gate git-lfs auto-install on provisioned hosts, matching ensureGit #828 without regressing the case it was designed for.

Summary by CodeRabbit

  • Bug Fixes
    • Package-manager installation is now restricted to environments with the required permissions.
    • Installations verify that the destination directory exists and is writable before downloading files.
    • Missing destination directories are created automatically, while read-only locations are rejected with an error.

isLocalAgent gates auto-install on "is this a local-docker provider"
vs "is this a remote/SSH provider" (#828), but that's not the same as
"does devsy have install rights here." A remote SSH machine provider
running as an unprivileged user is non-local yet still gets a
permission-denied apt/github-release install attempt on every clone,
identical to the noise the original fix was meant to remove.

pkgManagerStrategy.usable() now also requires root (apt/dpkg need it
regardless of host type), and the release strategy checks the install
directory is actually writable before downloading anything, so a
guaranteed-to-fail install is never attempted rather than attempted
and then failing loudly.
@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for images-devsy-sh canceled.

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

@coderabbitai

coderabbitai Bot commented Jul 31, 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: 49 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: b1a87795-b866-4d39-b580-a63836949061

📥 Commits

Reviewing files that changed from the base of the PR and between c970e9e and 9992ae9.

📒 Files selected for processing (1)
  • pkg/git/installer_release.go
📝 Walkthrough

Walkthrough

The installer now requires root privileges for package-manager strategies. It also validates that the installation directory exists or can be created and written before downloading the executable. Tests cover privilege and directory-validation behavior.

Changes

Installer validation

Layer / File(s) Summary
Root-gated package-manager strategies
pkg/git/installer.go, pkg/git/installer_test.go
Package-manager strategies require both an available manager and root privileges. Tests cover root and non-root conditions.
Installation directory writability
pkg/git/installer_release.go, pkg/git/installer_test.go
Installation validates directory creation and write access before proceeding. Tests cover existing, missing, and read-only directories.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 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 clearly summarizes the root and write-capability checks added before git-lfs installation.
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.

@netlify

netlify Bot commented Jul 31, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 9992ae9
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/6a6c213267ca7b0008034f19

@skevetter
skevetter marked this pull request as ready for review July 31, 2026 03:17
@skevetter skevetter changed the title fix(git): check real write/root capability before installing git-lfs fix(git): check write/root capability before installing git-lfs Jul 31, 2026
@skevetter
skevetter marked this pull request as draft July 31, 2026 03:27
@skevetter
skevetter marked this pull request as ready for review July 31, 2026 04:03

@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/installer_release.go`:
- Around line 219-221: Update the probe cleanup flow around probe.Close so its
error is captured and returned after attempting os.Remove(name). Preserve
best-effort removal, but ensure a non-nil close error takes precedence over a
successful removal result, preventing the writability check from reporting
success.
🪄 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: 51db9bdd-8786-4e5d-95b6-a057c7b120d7

📥 Commits

Reviewing files that changed from the base of the PR and between 2ebb3cc and c970e9e.

📒 Files selected for processing (3)
  • pkg/git/installer.go
  • pkg/git/installer_release.go
  • pkg/git/installer_test.go

Comment thread pkg/git/installer_release.go
A failed close (e.g. deferred write errors on some filesystems) was
silently discarded, letting a doomed writability check report success.
@skevetter
skevetter enabled auto-merge (squash) July 31, 2026 04:39
@skevetter
skevetter merged commit 46790ca into main Jul 31, 2026
66 checks passed
@skevetter
skevetter deleted the fix/lfs-install-privilege-check branch July 31, 2026 05:02
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