Skip to content

fix(cli): fall back to regular upload when git filtering excludes all files#1783

Open
russellb wants to merge 7 commits into
NVIDIA:mainfrom
russellb:fix/upload-empty-gitignore-fallback
Open

fix(cli): fall back to regular upload when git filtering excludes all files#1783
russellb wants to merge 7 commits into
NVIDIA:mainfrom
russellb:fix/upload-empty-gitignore-fallback

Conversation

@russellb
Copy link
Copy Markdown
Contributor

@russellb russellb commented Jun 5, 2026

Summary

When uploading a directory whose contents are entirely excluded by .gitignore, git_sync_files returns an empty file list. The git-aware upload path silently accepted this and printed "Upload complete" without transferring any files. Now both call sites check for an empty file list and fall through to the regular, unfiltered upload path instead.

Related Issue

Closes #1778

Changes

  • main.rs: Added !files.is_empty() guard to the git-aware upload branch so an empty git file list falls through to the regular upload
  • run.rs: Added the same guard in sandbox_upload_plan() so the sandbox run upload path also falls back correctly
  • Added test sandbox_upload_plan_falls_back_when_all_files_gitignored confirming a gitignored directory produces a Regular upload plan

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)

@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Jun 5, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

maxamillion
maxamillion previously approved these changes Jun 5, 2026
@TaylorMutch
Copy link
Copy Markdown
Collaborator

/ok to test 6d322fd

@johntmyers johntmyers added the gator:in-review Gator is reviewing or awaiting PR review feedback label Jun 5, 2026
@johntmyers
Copy link
Copy Markdown
Collaborator

johntmyers commented Jun 5, 2026

gator-agent

PR Review Status

Validation: This PR is project-valid because it directly fixes validated issue #1778 for sandbox upload silently doing a zero-file transfer when git filtering excludes every file.
Head SHA: 6d322fdbffc4aeb3e8b1df5061456f301679d67b

Independent review: completed in this cycle. No critical correctness blockers were found in the core fallback or regression coverage.

Review feedback still needs author or maintainer resolution before pipeline handoff:

  • The fallback from git-filtered upload to unfiltered upload is silent. Because CLI help says .gitignore filtering applies by default, this can surprise users and may upload ignored files they expected to stay local. Please either:
    • print a short stderr notice when git filtering returns an empty list and OpenShell falls back to unfiltered upload, including the sandbox create --upload path; or
    • add a maintainer-confirmed rationale that silent fallback is intentional.
  • Docs: this is a direct CLI/sandbox upload behavior change. Please add a short note under docs/sandboxes/manage-sandboxes.mdx explaining default gitignore filtering and this empty-filter fallback, or have a maintainer state that docs are intentionally unnecessary.

E2E: This change affects sandbox file transfer behavior and adds an E2E regression test, so test:e2e should be applied once review feedback is resolved.

Next state: gator:in-review

russellb added 3 commits June 8, 2026 11:40
… files

When uploading a directory whose contents are entirely excluded by
.gitignore, git_sync_files returns an empty file list. The git-aware
upload path silently accepted this and printed "Upload complete" without
transferring any files. Now both call sites (direct CLI handler and
sandbox_upload_plan) check for an empty file list and fall through to the
regular, unfiltered upload path instead.

Closes NVIDIA#1778

Signed-off-by: Russell Bryant <rbryant@nvidia.com>
…#1778)

Reproduces the reported workflow: download a file from a sandbox into a
local git repo where the target directory is gitignored, then re-upload
that directory without --no-git-ignore. Before the fix the upload
silently succeeded with zero files transferred.

Signed-off-by: Russell Bryant <rbryant@nvidia.com>
Address PR review: print a notice when .gitignore filtering excludes
all files and the CLI falls back to unfiltered upload. Add a
GitFilteredEmpty variant to SandboxUploadPlan so the caller can
distinguish this case and emit a visible warning. Document the
default gitignore filtering and fallback behavior in manage-sandboxes.
@russellb russellb force-pushed the fix/upload-empty-gitignore-fallback branch from 6d322fd to 7cc189a Compare June 8, 2026 15:49
@johntmyers
Copy link
Copy Markdown
Collaborator

gator-agent

Re-check After Author Update

I re-evaluated latest head 7cc189a14484c138331262dfcf158b308d42a17c after russellb's 2026-06-08 15:47 UTC commit, fix(cli): warn on stderr when gitignore fallback triggers.

Disposition: partially resolved.

Resolved items:

  • Docs were added under docs/sandboxes/manage-sandboxes.mdx for the default .gitignore filtering and empty-filter fallback behavior.
  • sandbox create --upload now uses SandboxUploadPlan::GitFilteredEmpty and prints a visible warning before falling back to an unfiltered upload.

Remaining items:

  • Direct openshell sandbox upload still falls back silently. In crates/openshell-cli/src/main.rs, the SandboxCommands::Upload branch checks !files.is_empty() before using the git-aware path, then falls through to sandbox_sync_up without warning when git_sync_files(local) succeeds with an empty list. Because this can upload ignored files the user expected to stay local, please add the same visible warning for this direct upload path before falling back.
  • The new E2E covers that the file is transferred, but it does not assert the warning. The existing upload_with_gitignore() helper returns combined stdout/stderr, so please capture that output and assert it contains the fallback warning once the direct upload path emits it.

Independent review: completed for the current head and found the same remaining warning-path gap; no other blocking findings were identified.

Next state: gator:in-review

The SandboxCommands::Upload path in main.rs had the same silent
fallback as sandbox_create. Restructure the git_sync_files check to
emit the same .gitignore warning before falling back to unfiltered
upload. Assert the warning in the E2E regression test.
@johntmyers
Copy link
Copy Markdown
Collaborator

gator-agent

Re-check After Author Update

I re-evaluated latest head e7fb5c153b0bdd3701a4412d2977059e0b725db7 after russellb's 2026-06-08 17:02 UTC commit, fix(cli): warn on stderr for direct upload gitignore fallback.

Disposition: partially resolved.

Resolved items:

  • Direct openshell sandbox upload now prints a visible .gitignore fallback warning before using the unfiltered upload path.
  • The new E2E now asserts the fallback warning appears in the upload output.
  • The sandbox create --upload path still uses the explicit GitFilteredEmpty plan and warns before fallback.

Remaining items:

  • docs/sandboxes/manage-sandboxes.mdx says users can "use sandbox upload with an explicit file list," but sandbox upload accepts one local_path plus an optional dest, not a file list. A gitignored single file can also trigger this fallback, so that guidance is misleading. Please revise that sentence, for example:
If `.gitignore` filtering excludes every file in the upload path, the CLI falls
back to an unfiltered upload and prints a warning. Pass `--no-git-ignore` to
opt into unfiltered uploads explicitly, upload a path outside the Git work
tree, or force-add the intended files if they should remain Git-aware.

Independent review: completed for the current head and found the same docs wording issue; no other blocking findings were identified.

Next state: gator:in-review

Replace inaccurate "explicit file list" advice with actionable
alternatives: --no-git-ignore, uploading outside the work tree,
or git force-adding the files.
@johntmyers johntmyers added gator:watch-pipeline Gator is monitoring PR CI/CD status test:e2e Requires end-to-end coverage and removed gator:in-review Gator is reviewing or awaiting PR review feedback labels Jun 8, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 8, 2026

Label test:e2e applied, but pull-request/1783 is at 6d322fd while the PR head is 1e0ce41. A maintainer needs to comment /ok to test 1e0ce410b912427183aef876163b2a18f307404c to refresh the mirror. Once the mirror catches up, re-run Branch E2E Checks from the Actions tab.

@johntmyers
Copy link
Copy Markdown
Collaborator

gator-agent

Re-check After Author Update

I re-evaluated latest head 1e0ce410b912427183aef876163b2a18f307404c after russellb's 2026-06-08 17:58 UTC commit, docs(sandboxes): fix misleading upload fallback guidance.

Disposition: resolved.

Remaining items:

  • No blocking review items remain. The prior docs wording issue is fixed, the direct upload fallback warning is present, and the E2E regression asserts the fallback warning.

Docs: updated under docs/sandboxes/manage-sandboxes.mdx; no navigation update is needed.

E2E: applied test:e2e because this changes sandbox upload behavior.

Next state: gator:watch-pipeline

@johntmyers
Copy link
Copy Markdown
Collaborator

/ok to test 1e0ce41

@johntmyers
Copy link
Copy Markdown
Collaborator

gator-agent

Pipeline Failure

CI failed for latest head 1e0ce410b912427183aef876163b2a18f307404c.

OpenShell / Branch Checks failed in both Rust jobs during mise run rust:lint because clippy reports clippy::collapsible_if in crates/openshell-cli/src/run.rs:5819:

error: this `if` statement can be collapsed
--> crates/openshell-cli/src/run.rs:5819:5

This appears PR-caused and needs an author update. The E2E workflow is still running, but the required branch gate cannot pass until the clippy failure is fixed.

Next state: gator:in-review

@johntmyers johntmyers added gator:in-review Gator is reviewing or awaiting PR review feedback and removed gator:watch-pipeline Gator is monitoring PR CI/CD status labels Jun 8, 2026
@johntmyers
Copy link
Copy Markdown
Collaborator

gator-agent

Re-check After Author Update

I re-evaluated latest head c21f8c937b82252947520be234638a7d69020801 after russellb's 2026-06-08 18:47 UTC commit, fix(cli): collapse nested ifs to satisfy clippy::collapsible_if.

Disposition: resolved.

Remaining items:

  • No blocking review items remain. The clippy-triggering nested if form was collapsed while preserving the direct sandbox upload warning path and the sandbox create --upload GitFilteredEmpty warning path.
  • Independent review completed for the latest diff and found no critical or warning-level findings. It only noted a non-blocking suggestion that the warning could someday distinguish .gitignore exclusions from a genuinely empty upload directory.

Docs: updated under docs/sandboxes/manage-sandboxes.mdx; no navigation update is needed.

E2E: test:e2e is already applied because this changes sandbox upload behavior.

Next state: gator:watch-pipeline

@johntmyers johntmyers added gator:watch-pipeline Gator is monitoring PR CI/CD status and removed gator:in-review Gator is reviewing or awaiting PR review feedback labels Jun 8, 2026
@johntmyers
Copy link
Copy Markdown
Collaborator

/ok to test c21f8c9

@johntmyers
Copy link
Copy Markdown
Collaborator

gator-agent

Pipeline Failure

CI failed for latest head c21f8c937b82252947520be234638a7d69020801.

OpenShell / Branch Checks failed in both Rust jobs during the Format step:

  • Rust (linux-amd64-cpu8) failed at Format
  • Rust (linux-arm64-cpu8) failed at Format

This appears PR-caused and needs an author update. The E2E workflow is still running, but the required branch gate cannot pass until the formatting failure is fixed.

Next state: gator:in-review

@johntmyers johntmyers added gator:in-review Gator is reviewing or awaiting PR review feedback and removed gator:watch-pipeline Gator is monitoring PR CI/CD status labels Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gator:in-review Gator is reviewing or awaiting PR review feedback test:e2e Requires end-to-end coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An issue on "openshell sandbox upload/download"

4 participants