Skip to content

fix(exec): emit JSON error payload on startup and store failure - #34

Open
adi-IL wants to merge 1 commit into
e2b-dev:mainfrom
adi-IL:fix/exec-json-contract
Open

fix(exec): emit JSON error payload on startup and store failure#34
adi-IL wants to merge 1 commit 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

Per ADR-0004, src/exec.js guarantees emitting exactly one JSON object on stdout for all execution and error states so programmatic consumers (such as e2b-bench and automated grading harnesses) can reliably parse results without raw stderr crashes.

Previously, invalid JSON payloads passed via CLI arguments, store read errors, or credential configuration errors threw unhandled exceptions prior to the runner's try/catch block.

This patch:

  • Catches invalid JSON payload errors from JSON.parse and routes them through emit({ error: ... }).
  • Handles store read errors from readRecord(key) through emit().
  • Guards loadConfig() and sdkConn() to return structured JSON errors when credentials or configurations fail.
  • Adds test coverage in test/exec.test.js.

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

1 participant