Repository navigation
bug(cli): stop uploads when Git filtering fails or selects no files #3847
Description
Activity
I would like to work on this. I checked current open PRs and did not find an implementation covering the fail-closed upload behavior. I will keep the change focused on stopping Git-filtered uploads on filtering errors or empty selections, preserve the explicit --no-git-ignore override, and update regression coverage for both upload entry points.
I reviewed CONTRIBUTING after the initial triage. Since this issue does not yet have an accepted lifecycle state and first-time contributors require a maintainer vouch before submitting, I will wait for that project-side gate rather than start substantial implementation prematurely.
🏗️ build-plan
Implementation Plan
Issue type:
fix
Complexity: Low
Confidence: HighSummary
Make the shared upload planner return an error when Git filtering fails or selects no files. Both upload entry points will require the existing
--no-git-ignoreoverride for intentional unfiltered uploads; preserve the existing symlink handling.Scope and Implementation Steps
- Update
sandbox_upload_planincrates/openshell-cli/src/run.rs, retain the underlying error with actionable guidance, and remove the empty-selection fallback variant and both callers' fallback branches. - Update planner unit tests and CLI subprocess regression tests for ignored/empty selections, unavailable/failing Git, non-repository paths, successful filtering, and explicit override.
- Change the shared file-transfer conformance scenario to verify rejection, no remote output, and successful explicit unfiltered retry.
- Update sandbox upload documentation, the gateway architecture transfer overview, and the public CLI skill.
Test Plan
- Run focused CLI unit and subprocess tests, conformance crate checks, project tests, and pre-commit checks.
- Run the Git-filtering conformance scenario against a gateway if the local runtime is available.
- Run full local CI before opening a PR; report environment blockers precisely if any.
Risks and Open Questions
- Non-repository paths also require
--no-git-ignore, because Git cannot apply repository filtering there. - Creation-time planning remains after provisioning; failure stops the affected transfer, not sandbox creation or earlier successful uploads.
- No changes to gateway configuration, isolation, or symlink semantics are planned.
Documentation Impact
Update
docs/how-it-works/sandboxes/overview.mdx,architecture/gateway.md, andskills/openshell-cli/SKILL.md. Navigation is unchanged.
Revision 1 — initial plan. Direct implementation request; lifecycle and queue labels left unchanged.
- Update
User Story
As an OpenShell user uploading files to a sandbox, I want the default
.gitignorefiltering to be respected, so that only the files I intended to upload are transferred.Problem Statement
Uploads use Git to apply filtering by default, but currently fall back to uploading the selected path without filtering when:
This affects both
sandbox uploadandsandbox create --upload. The CLI already has--no-git-ignorefor explicitly requesting an unfiltered upload.This came up during Codex-assisted review of PR #3795, where Git needed to be added to the Snap package definition for the upload conformance tests to pass. Packaging Git addresses that particular trigger, but leaves the fallback behavior in place.
Impact / Why This Matters
The CLI can transfer ignored local files that the user did not intend to include. A warning after filtering selects nothing does not give the user a chance to stop that upload.
Users can work around this by staging only the intended files in a separate directory. That requires manual checking and copying despite filtering being enabled by default. Installing Git avoids the missing-executable case but does not cover other Git failures or an empty filtered selection.
Acceptance Criteria
--no-git-ignorecan be used for an intentional unfiltered upload.sandbox uploadandsandbox create --upload.--no-git-ignorecontinues to allow unfiltered uploads.Reproduction Steps
Proposed reproduction with dummy files and a disposable sandbox; not run end-to-end during issue preparation:
runs/to.gitignore, and createruns/marker.txtcontaining dummy text.openshell sandbox upload <sandbox> <repo>/runs <destination>without--no-git-ignore.sandbox create --upload.Expected: stop on filtering failure or an empty selection; require
--no-git-ignorefor an intentional unfiltered retry.Environment
9f60f55c6b0811b1651099b50e4618d435ebc02e.Code References
Static inspection confirms the fallback in
crates/openshell-cli/src/run.rs:sandbox_upload_plan()discards errors fromgit_sync_files()through anif let Ok(...)condition and falls through toRegular.GitFilteredEmptyby warning and calling the unfilteredsandbox_sync_up().sandbox_upload_plan_falls_back_when_all_files_gitignoredcurrently tests the empty-selection fallback and will need updating.