Skip to content

fix(code-interpreter): preserve result data in JSON - #1939

Open
pei711 wants to merge 1 commit into
e2b-dev:mainfrom
pei711:fix/code-interpreter-data-serialization
Open

pei711 wants to merge 1 commit into
e2b-dev:mainfrom
pei711:fix/code-interpreter-data-serialization

Conversation

@pei711

@pei711 pei711 commented Oct 3, 2026 •

Copy link
Copy Markdown

Fixes #1938.

Problem and change

Serializing Code Interpreter executions drops Result.data in JavaScript and drops empty data objects in Python. Preserve that field when supplied, including {}, while keeping absent data out of the serialized result. Python sync and async code paths share the corrected result model.

The production fix is one line in each SDK. Added JS and sync/async Python parser-to-serialization regressions and a patch changeset for both Code Interpreter packages.

Usage

const saved = JSON.parse(JSON.stringify(execution))
// saved.results[0].data now retains the structured data from the result.
saved = json.loads(execution.to_json())
# saved['results'][0]['data'] now retains an empty data object too.

Validation

  • Before the fix: 2 JS regressions fail; 2 Python empty-data regressions fail. Absent data and populated Python data already pass.
  • JS offline messaging, serialization, sandbox-URL and kernel-readiness tests: 16 passed.
  • Python offline serialization, diagnostics, timeout, sandbox-URL and kernel-readiness tests: 38 passed.
  • Code Interpreter JS lint, TypeScript check, changed-file Prettier check and base JS SDK build pass.
  • Built Code Interpreter JS package passes a real loopback HTTP fixture through Sandbox.connect / runCode, then JSON serialization preserves empty and populated data. This allocates no cloud sandbox and performs no real code execution.
  • Code Interpreter Python package-wide Ruff lint/format and ty check e2b_code_interpreter pass.
  • git diff --check passes.

Tested on Windows with Node 24.13.1, Python 3.13.12 and pinned pnpm 10.34.5. The root pnpm run format, lint and typecheck wrappers were attempted; each stops when a Python package invokes make, which is unavailable here. The affected Python package's equivalent Ruff and ty commands passed directly through uv. Cloud sandbox tests and other runtimes were not run; these checks make no sandbox or provider calls.

This PR was fully generated with OpenAI Codex, including code, tests and description. Codex reviewed the change and ran the checks above; no human review is claimed.


Devin Review

@pei711
pei711 requested a review from mishushakov as a code owner October 3, 2026 12:42
@cla-bot

cla-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @pei711 on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@changeset-bot

changeset-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 1549d0e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/code-interpreter Patch
@e2b/code-interpreter-python Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration devin-ai-integration Bot 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.

TASTE.md review: no violations. The diff touches only Result serialization; checked parity (T-1), empty-object-as-present (T-13), undefined for absence (T-20), and docstrings (T-69). With this change, JS and Python both report data in formats() and serialize it, including {}, and both leave it out when it is missing or null.

Written by Devin

@pei711

pei711 commented Oct 3, 2026

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Oct 3, 2026
@cla-bot

cla-bot Bot commented Oct 3, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

This branch has not been deployed

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

[Bug]: Code Interpreter JSON serialization drops Result.data

1 participant