Skip to content

fix: preserve dash-prefixed sandbox copy paths - #31

Closed
Kayvan-Zahiri wants to merge 2 commits into
basetenlabs:mainfrom
Kayvan-Zahiri:codex/copy-dash-paths
Closed

Kayvan-Zahiri wants to merge 2 commits into
basetenlabs:mainfrom
Kayvan-Zahiri:codex/copy-dash-paths

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown

Relative source paths beginning with - cannot reliably be copied with Sandbox.fs.copy: shell quoting preserves the string, but cp still interprets it as an option. For example, copying -source to copy fails instead of copying an existing file.

Add -- before the two quoted operands in the command shared by sync and async copy. Existing quoting and process completion handling remain intact.

Validation: six public sync/async API regression cases execute the emitted command against temporary local files (four fail before the change, six pass after). Full suite: 449 passed, 86 skipped. Repository lint and type checks, wheel/sdist builds and git diff --check pass. Live Baseten E2E tests were skipped; this reproduces command construction locally through HTTPX mock transport. Developed with AI assistance and verified locally.

@CLAassistant

CLAassistant commented Oct 19, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Comment thread baseten/sandbox/_fs.py

@cretz cretz Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Hi, just noticed this draft PR. Let me know if this is something you are hitting and when it is ready for review.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not in production. I found it while reading the copy code: a source path starting with - gets parsed by cp as an option. It's ready for review now, thanks for taking a look.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

To confirm, you are not a Baseten user hitting this issue at this time? Or is this just from a scan and you aren't using this code yourself?

This also exists in other SDKs and in Blaxel at https://github.com/blaxel-ai/sdk-python/blob/e9b63fd6bf8eabd02c451510a733e29615644fbf/src/blaxel/core/sandbox/sync/filesystem.py#L175 and in other places. I want to confirm impact.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Right, I'm not a Baseten user and haven't hit this myself. I found it while reading through sandbox SDK code, so it comes from a review, not a bug report. The impact is small: it only affects a relative path that starts with -, since absolute paths always start with /. If that isn't worth a change on your side, I'm fine with closing it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is less of a concern at this time. I do think we'll close it and when we tackle, we can do it across all 3 SDKs.

@Kayvan-Zahiri
Kayvan-Zahiri marked this pull request as ready for review October 19, 2026 18:55
Copilot AI balanced review requested due to automatic review settings October 19, 2026 18:55

Copilot AI 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.

🟢 Approval recommended

The focused fix preserves existing behavior and has regression coverage for both APIs, with no unresolved findings.

No open issues 🎉

What changed in this PR

Fixes Sandbox.fs.copy so dash-prefixed paths are treated as operands rather than command options in both sync and async APIs.

Changes:

  • Adds -- before copy operands while preserving shell quoting.
  • Adds six regression cases and updates the existing command assertion.
File Description
tests/​sandbox/​test_fs.py Updates the expected copy command.
tests/​sandbox/​test_copy_paths.py Tests dash-prefixed paths through both APIs.
baseten/​sandbox/​_fs.py Ends option parsing before copy operands.

Review effort: Balanced

@cretz cretz closed this Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants