Skip to content

fix(mount): align late-bound path validation - #34

Open
khaliqgant wants to merge 1 commit into
mainfrom
fix/mount-layout-contract-0823
Open

fix(mount): align late-bound path validation#34
khaliqgant wants to merge 1 commit into
mainfrom
fix/mount-layout-contract-0823

Conversation

@khaliqgant

@khaliqgant khaliqgant commented Aug 23, 2026

Copy link
Copy Markdown
Member

Summary

Keeps the sandbox and Cloud vendored late-bound mount templates on the same validation contract after #31 and #33.

Dynamic template arguments now fail closed when a remote root is non-absolute or normalizes to the empty root. Static builders already reject those forms through scopedRemoteRoots; this makes the public late-bound template path behave identically and matches the Cloud #3143 port.

Validation

  • targeted mount/lifecycle tests: 24 passed
  • typecheck: passed
  • git diff --check: passed
  • new regressions assert visible status-2 failures for non-absolute and root-empty inputs

Release scope

The critical sentinel correction is already in published 0.1.7 from #33. Normal generated path arguments already pass through buildRelayfileMountPathArgsShell, so this follow-up is validation parity and hardening rather than a blocker for the current production mount recovery.

No version bump, merge, publish, deploy, or image rebuild was performed.


Summary by cubic

Aligns late-bound mount path validation with static builders and Cloud. Previously, dynamic mounts accepted non-absolute or root-empty remote roots; now they fail closed with exit status 2 and clear errors.

  • Shell preflight now requires the remote root start with “/” and rejects paths that normalize to empty; traversal checks remain.
  • Tests assert status-2 failures for relative paths and “/”.
  • Migration: callers must pass an absolute, non-empty remote root path.
  • No version bump or deploy; validation parity and hardening only.

Written for commit f9ca226. Summary will update on new commits.

Review in cubic

@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 3 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 667314af-a6f9-4db8-95bd-1490bca75de8

📥 Commits

Reviewing files that changed from the base of the PR and between a58012a and f9ca226.

📒 Files selected for processing (2)
  • src/mount-script.test.ts
  • src/mount-script.ts

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.

@khaliqgant

Copy link
Copy Markdown
Member Author

@codex review

Please review exact head f9ca226 for semantic parity with the Cloud vendored preflight: late-bound non-absolute and root-empty path arguments must fail visibly without changing valid generated paths.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f9ca2268e5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mount-script.ts
Comment on lines 790 to +792
'relayfile_mount_remote_suffix="${relayfile_mount_remote_path#/}";',
'relayfile_mount_remote_suffix="${relayfile_mount_remote_suffix%/}";',
'if [ -z "$relayfile_mount_remote_suffix" ]; then echo "relayfile remote root must not be empty" >&2; exit 2; fi;',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Reject every all-slash remote root

When a late-bound argument is --remote-path '//' (or contains more slashes), ${var#/} and ${var%/} each remove only one slash, so the suffix remains nonempty and this check permits the root-equivalent path. The template then starts a daemon against the local mount root instead of visibly rejecting the root-empty argument; strip all leading/trailing slashes or explicitly reject an all-slash value.

Useful? React with 👍 / 👎.

@kjgbot kjgbot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Review from sandbox-lead-0823. Ratifying — no concerns. Khaliq owns the merge gate.

Diff is minimal and well-scoped: two additional preflight guards in dynamicMountPreflight — one case */) check enforcing an absolute-path prefix, one if -z check on the normalized suffix — with matching test cases ('github/repos/acme/cloud' → status 2, '/' → status 2). The traversal-segment guard that already existed is preserved, so the three checks now cover the full set: absolute-prefix, no-traversal, non-empty-normalized-suffix. That matches the "static builders already reject through scopedRemoteRoots; make the late-bound template behave identically" framing in the body.

Fail-closed error messages are precise (relayfile remote root must be absolute / must not be empty), match the test assertions, and are distinguishable from the pre-existing traversal error. Exit status 2 is the same status used by the neighbouring guards, so callers that already special-case a preflight failure don't need to grow a new branch.

No release scope tail on this one (as the body notes) — 0.1.7 already carries the sentinel correction from #33, and the normal generated-path path goes through buildRelayfileMountPathArgsShell, so this is parity hardening rather than a prod unblock. All four automated checks (Build & Test, cubic, CodeRabbit, Devin) are green.

Ready from my side.

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.

2 participants