Skip to content

sandbox upload overwrites existing file with a directory instead of replacing file contents #667

@mjamiv

Description

@mjamiv

Summary

openshell sandbox upload <sandbox> <local_path> <remote_dest> creates a directory at the destination path instead of overwriting the existing file when the remote destination already exists as a file.

Steps to Reproduce

  1. Ensure a file already exists inside the sandbox at the destination path, e.g. /sandbox/.bashrc
  2. Run the upload command targeting that same path:
    openshell sandbox upload agent /tmp/updated-bashrc /sandbox/.bashrc
    
  3. Inspect the remote path inside the sandbox:
    openshell sandbox exec agent -- ls -la /sandbox/.bashrc
    

Expected Behavior

The existing file at /sandbox/.bashrc is overwritten with the contents of the local file /tmp/updated-bashrc.

Actual Behavior

A directory named .bashrc is created at /sandbox/.bashrc, and the uploaded file is placed inside it (e.g. /sandbox/.bashrc/updated-bashrc). The original file is silently replaced by a directory, breaking any process that expects a regular file at that path.

This is especially problematic for configuration file updates (.bashrc, openclaw.json, auth-profiles.json, etc.) where the silent replacement causes downstream failures that are difficult to diagnose.

Workaround

Use SSH to write files directly instead of openshell sandbox upload:

openshell sandbox exec agent -- bash -c 'cat > /sandbox/.bashrc' < /tmp/updated-bashrc

Alternatively, after the upload creates the directory, move the file out and remove the directory:

openshell sandbox exec agent -- bash -c 'mv /sandbox/.bashrc/updated-bashrc /tmp/fix && rmdir /sandbox/.bashrc && mv /tmp/fix /sandbox/.bashrc'

Environment

  • openshell version: 0.0.15 and 0.0.16
  • Platform: Linux x86_64 (Ubuntu)
  • Sandbox type: agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions