Skip to content

fix(code-interpreter): preserve Result.data in JSON serialization - #1971

Open
YidaWeng wants to merge 1 commit into
e2b-dev:mainfrom
YidaWeng:main
Open

YidaWeng wants to merge 1 commit into
e2b-dev:mainfrom
YidaWeng:main

Conversation

@YidaWeng

Copy link
Copy Markdown

Summary

  • Fix Result.toJSON() in JS SDK to include data field when present (previously omitted entirely)
  • Fix Execution.to_json() in Python SDK to preserve empty data objects (previously dropped due to truthiness check)
  • Change Python formats() to use is not None check instead of truthiness for data

Test plan

  • JS tests: Added 3 test cases for Result.toJSON with populated data, empty data, and undefined data
  • Python tests: Added 3 test cases for Execution.to_json with populated data, empty data, and None data
  • All existing tests pass
  • format, lint, and typecheck pass

Example

// Before: data was omitted
const result = new Result({ text: 'table', data: { columns: ['answer'], rows: [[42]] } }, true)
JSON.stringify(result) // { text: 'table' }

// After: data is preserved
JSON.stringify(result) // { text: 'table', data: { columns: ['answer'], rows: [[42]] } }
# Before: empty data was dropped
result = Result(text='table', data={})
execution.to_json() # '{"results": [{"text": "table"}]}'

# After: empty data is preserved
execution.to_json() # '{"results": [{"text": "table", "data": {}}]}'

Fixes #1938

Generated with Devin

Fix Result.toJSON() and Execution.to_json() to preserve the data field when present, including empty objects. Previously, the JS SDK omitted data entirely from serialization, and the Python SDK dropped empty data objects due to a truthiness check in formats().

- JS: Add data field to toJSON() when not undefined
- Python: Change data truthiness check to is not None in formats()
- Add tests for both SDKs covering populated, empty, and undefined data

Fixes e2b-dev#1938

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@YidaWeng
YidaWeng requested a review from mishushakov as a code owner October 10, 2026 05:31
@cla-bot

cla-bot Bot commented Oct 10, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @YidaWeng 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 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e590562

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-10T05:34:01.936888Z e590562 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@YidaWeng

Copy link
Copy Markdown
Author

@cla-bot check

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

cla-bot Bot commented Oct 10, 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