Skip to content

Add aio runtime sandbox exec command#430

Open
riddhi2910 wants to merge 3 commits into
masterfrom
acna-4665
Open

Add aio runtime sandbox exec command#430
riddhi2910 wants to merge 3 commits into
masterfrom
acna-4665

Conversation

@riddhi2910

@riddhi2910 riddhi2910 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a new aio runtime sandbox exec command. it is the non-interactive counterpart to aio runtime sandbox run. It creates a sandbox, runs one or more commands, then tears the sandbox down.

Related Issue

https://jira.corp.adobe.com/browse/ACNA-4665

Motivation and Context

run is only for interactive use. It does not support -- <command> or commands from stdin. We also found that using file redirection could cause issues.

exec solves this problem. It reads all commands from stdin before running them, so exec < commands.txt works reliably. This gives us a simple way to run one-time commands or a list of commands in scripts, CI pipelines, or automation tools, while keeping run for interactive use.

How Has This Been Tested?

  1. npm lint
  2. npm test
  3. manually tried different exec commands by linking the local version to the aio cli
    e.g
printf 'echo from-stdin\n' | aio runtime sandbox exec -- echo from-flag
 ›   Warning: @adobe/aio-cli update available from 11.0.2 to 11.1.2.
 ›   Run npm install -g @adobe/aio-cli to update.
 ›   Warning: @adobe/aio-cli-plugin-api-mesh update available from 5.6.1 to 5.7.0
 ›   Warning: Run aio plugins:install @adobe/aio-cli-plugin-api-mesh to update to the latest

Creating sandbox...
[aio-lib-sandbox] alpha — APIs may change without notice
Created: sb-3db117e1d3122f1e
Network policy: default-deny (DNS + NATS only)

$ echo from-flag
from-flag
[exit: 0]

$ echo from-stdin
from-stdin
[exit: 0]
Sandbox destroyed.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

github-actions[bot]
github-actions Bot previously approved these changes Jun 11, 2026

@github-actions github-actions 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.

🤖 PR Reviewer

The new sandbox exec command is well-structured, clearly documented, and thoroughly tested. The code follows established patterns from the existing run command, handles error cases gracefully, and the test suite provides good coverage including edge cases. One minor issue: the copyright year says 2026 (future-dated) in both new files, and there's an unused import (shellQuote is imported in exec.js but only re-exported for testing, not used directly in the command logic — this is fine). Overall the implementation is solid.

LGTM! This PR looks good to merge.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

Comment thread src/commands/runtime/sandbox/exec.js
Comment thread test/commands/runtime/sandbox/exec.test.js
@codecov

codecov Bot commented Jun 11, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@MichaelGoberling MichaelGoberling 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.

Looks great! Just a few suggestions

Comment thread src/commands/runtime/sandbox/exec.js Outdated
shellQuote
} = require('../../../sandbox-helpers')

const COMMAND_TIMEOUT_MS = 30000

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.

Suggestion: DEFAULT_COMMAND_TIMEOUT_MS so its clear

Comment thread src/commands/runtime/sandbox/run.js Outdated

if (commandArgs.length > 0) {
this._failUsage('This command only supports interactive use. Omit "-- <command>" and type commands when prompted.')
this._failUsage('This command only supports interactive use. Omit "-- <command>" and type commands when prompted, or use "aio runtime sandbox exec" for one-shot or scripted commands.')

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.

I don't think "-- command" works with run, its solely for interactive sessions, so we can probably remove specifying this here

Comment thread src/commands/runtime/sandbox/exec.js Outdated
process.exitCode = 2
}

_logPolicy (policy) {

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.

Run and exec both use these identically I believe, would be good to have in the same place

Comment thread src/commands/runtime/sandbox/exec.js Outdated
})
}

async _logPreviewUrls (sandbox, ports) {

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.

Could add to a shared lib and re-use here as well I believe

@github-actions github-actions 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.

🤖 PR Reviewer

The diff is well-structured: it refactors shared logging helpers into sandbox-helpers.js, adds a clean non-interactive exec command with good test coverage, and updates error messages to reference the new command. One minor issue remains in the test file where the description assertion checks for 'sandbox run' instead of 'sandbox exec'. The copyright year concern was acknowledged as intentional by the author.

📝 1 suggestion(s) - Please review inline comments below.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

Comment thread test/commands/runtime/sandbox/exec.test.js
@github-actions github-actions Bot dismissed their stale review June 12, 2026 16:41

Superseded by new review

@github-actions github-actions 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.

🤖 PR Reviewer

The code is well-structured, with good separation of concerns (shared helpers extracted to sandbox-helpers.js), solid test coverage, and clear error handling. The previously raised description test issue has been fixed — the test now correctly matches /non-interactively/. No significant issues remain.

LGTM! This PR looks good to merge.


💡 How to re-trigger

Comment /review or /pr-reviewer on this PR

@github-actions github-actions Bot dismissed their stale review June 12, 2026 16:45

Superseded by new review

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