Skip to content

fix(sandbox): prevent shell option interpretation for paths with leading hyphens#25891

Merged
steipete merged 2 commits intoopenclaw:mainfrom
albertlieyingadrian:fix/sandbox-fs-syntax-error-on-dash-filenames
Feb 25, 2026
Merged

fix(sandbox): prevent shell option interpretation for paths with leading hyphens#25891
steipete merged 2 commits intoopenclaw:mainfrom
albertlieyingadrian:fix/sandbox-fs-syntax-error-on-dash-filenames

Conversation

@albertlieyingadrian
Copy link
Contributor

@albertlieyingadrian albertlieyingadrian commented Feb 24, 2026

Summary

  • Fix a critical bug where sandbox filesystem operations fail with Syntax error: ";" unexpected when file paths contain the --- pattern
  • Added ensurePathNotInterpretedAsOption() helper function that prepends "./" to paths starting with "-" to prevent shell option interpretation
  • Applied the fix to all fs-bridge operations: readFile, writeFile, mkdirp, remove, rename, stat, and resolveCanonicalContainerPath

Problem

After upgrading from 2026.2.22 to 2026.2.23, all sandbox filesystem operations (read, write, image) fail with:

moltbot-sandbox-fs: 1: Syntax error: ";" unexpected

This breaks ALL inbound media processing - agents cannot see photos, voice notes, or documents sent by users via Telegram.

Root Cause

Paths starting with "-" (including those containing "---" pattern in filenames like file_1095---f00a04a2-99a0-4d98-99b0-dfe61c5a4198.ogg) can be interpreted as shell options by the sh shell when passed as arguments to sh -c.

Solution

Added a helper function ensurePathNotInterpretedAsOption() that prepends "./" to paths starting with "-" to ensure they're always treated as file paths, not options.

Testing

  • Test with filename: file_1095---f00a04a2-99a0-4d98-99b0-dfe61c5a4198.ogg
  • Test with filename: file_1221---6c4f9947-8cbb-48a1-a834-e69c2bbfeaa2.md
  • Test with filename: file_1569---54dcf3f8-9874-4888-8f47-a5fb719f584f.md

Post-Deploy Monitoring & Validation

  • What to monitor/search
    • Logs: Search for moltbot-sandbox-fs.*Syntax error
  • Validation checks
    • Check if agents can read inbound media files via read, image tools
  • Expected healthy behavior
    • Agents can successfully read/process inbound media files with --- pattern in filename
  • Failure signal/rollback trigger
    • If Syntax error still appears in logs after deployment, revert

Greptile Summary

Fixed critical sandbox filesystem bug where paths starting with - (hyphen) were interpreted as shell options instead of file paths, causing all filesystem operations to fail with Syntax error: ";" unexpected. Added ensurePathNotInterpretedAsOption() helper that prepends ./ to hyphen-prefixed paths before passing them to shell commands. Applied consistently across all filesystem operations: readFile, writeFile, mkdirp, remove, rename, stat, and resolveCanonicalContainerPath.

  • Prevents shell option interpretation by prepending ./ to paths starting with - or --
  • Fixes media processing failures for files with --- pattern in filenames (e.g., file_1095---uuid.ogg)
  • Uses standard POSIX path normalization technique compatible with all shell -- argument terminators
  • Applied to all 7 filesystem operations and internal path resolution for complete coverage

Confidence Score: 5/5

  • Safe to merge - fixes critical production bug with defensive, standards-compliant implementation
  • Implementation uses well-established POSIX shell escaping pattern (./ prefix for hyphen-prefixed paths), is consistently applied across all filesystem operations, works correctly with existing -- argument terminators in shell scripts, and has comprehensive coverage. The fix addresses a real production issue affecting media processing without introducing new attack vectors.
  • No files require special attention

Last reviewed commit: b23a548

(2/5) Greptile learns from your feedback when you react with thumbs up/down!

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Feb 24, 2026
albertlieyingadrian and others added 2 commits February 25, 2026 01:16
…ing hyphens

Paths starting with "-" (like those containing "---" pattern) can be
interpreted as shell options by the sh shell. This fix adds a helper
function that prepends "./" to paths starting with "-" to prevent
this interpretation.

This fixes the issue where sandbox filesystem operations fail with
"Syntax error: ; unexpected" when file paths contain the "---" pattern
used in auto-generated inbound media filenames like:
file_1095---f00a04a2-99a0-4d98-99b0-dfe61c5a4198.ogg

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@steipete steipete force-pushed the fix/sandbox-fs-syntax-error-on-dash-filenames branch from b23a548 to 3951fc7 Compare February 25, 2026 01:40
@steipete steipete merged commit c7ae4ed into openclaw:main Feb 25, 2026
@steipete
Copy link
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm check + pnpm build + pnpm test (full-suite flaky on unrelated tests in this environment), pnpm check:docs, and targeted pnpm vitest run src/agents/sandbox/fs-bridge.test.ts
  • Land commit: 3951fc7
  • Merge commit: c7ae4ed

Thanks @albertlieyingadrian!

@albertlieyingadrian
Copy link
Contributor Author

Your welcome! @steipete

@albertlieyingadrian albertlieyingadrian deleted the fix/sandbox-fs-syntax-error-on-dash-filenames branch February 25, 2026 05:39
margulans pushed a commit to margulans/Neiron-AI-assistant that referenced this pull request Feb 25, 2026
Jackson3195 pushed a commit to Jackson3195/openclaw-with-a-personal-touch that referenced this pull request Feb 25, 2026
brianleach pushed a commit to brianleach/openclaw that referenced this pull request Feb 26, 2026
execute008 pushed a commit to execute008/openclaw that referenced this pull request Feb 27, 2026
r4jiv007 pushed a commit to r4jiv007/openclaw that referenced this pull request Feb 28, 2026
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 1, 2026
… (thanks @albertlieyingadrian)

(cherry picked from commit c7ae4ed)

# Conflicts:
#	CHANGELOG.md
#	src/agents/sandbox/fs-bridge.ts
hughdidit pushed a commit to hughdidit/DAISy-Agency that referenced this pull request Mar 3, 2026
… (thanks @albertlieyingadrian)

(cherry picked from commit c7ae4ed)

# Conflicts:
#	CHANGELOG.md
#	src/agents/sandbox/fs-bridge.ts
zooqueen pushed a commit to hanzoai/bot that referenced this pull request Mar 6, 2026
thebenjaminlee pushed a commit to escape-velocity-ventures/openclaw that referenced this pull request Mar 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants