Skip to content

fix(exec): preserve JSON results for input and setup errors - #34

Merged
OndrejDrapalik merged 3 commits into
e2b-dev:mainfrom
adi-IL:fix/exec-json-contract
Sep 7, 2026
Merged

OndrejDrapalik merged 3 commits into
e2b-dev:mainfrom
adi-IL:fix/exec-json-contract

Conversation

@adi-IL

@adi-IL adi-IL commented Aug 30, 2026 •

Copy link
Copy Markdown
Contributor

Malformed CLI input and configuration/credential failures could crash exec.js before it emitted the JSON result consumed by the grader. Validate the key, command and timeout, and route JSON parsing and configuration errors through the existing result emitter. Failed setup returns one JSON object with ok:false and exitCode:null.

The store keeps its existing behavior: missing or malformed records return the no-sandbox JSON error. Numeric timeout strings remain supported. Invalid timeout values are rejected before coercion or SDK activity.

Four isolated CLI tests pass, covering malformed/null input, invalid field and timeout types, missing/corrupt records, missing credentials and invalid configuration. Fixtures use temporary HOME, config and record directories.

Per ADR-0004, src/exec.js guarantees emitting exactly one JSON object
on stdout for all outcomes so programmatic callers like the grader and
e2b-bench can reliably parse the result.

Previously, invalid CLI JSON payload arguments, store reading errors, or
config loading failures threw unhandled exceptions before reaching the
runner's try/catch block, dumping stack traces to stderr and violating
the stdout JSON contract.

Wrap payload parsing, store reading, and config loading in try/catch
blocks that route errors through emit().
@cla-bot cla-bot Bot added the cla-signed label Aug 30, 2026
@OndrejDrapalik OndrejDrapalik changed the title fix(exec): emit JSON error payload on startup and store failure fix(exec): preserve JSON results for input and setup errors Sep 7, 2026

@OndrejDrapalik OndrejDrapalik left a comment

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.

Input validation now prevents malformed values from escaping the JSON error contract. The isolated tests cover missing/corrupt records, credentials and configuration errors, and the redundant store catch is removed. Fresh CI passed across Node 22/24 on Ubuntu/macOS and the Rust/version checks.

@OndrejDrapalik
OndrejDrapalik merged commit 11943a4 into e2b-dev:main Sep 7, 2026
7 checks passed
@OndrejDrapalik OndrejDrapalik mentioned this pull request Sep 7, 2026
2 of 4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants