Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Improve write file handling

Jakub Novak9ec57c7c3969
diff --git a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py
index 0d1182168..ae2ee79a8 100644
--- a/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox_async/filesystem/filesystem.py
@@ -117,7 +117,13 @@ class Filesystem:
if err:
raise err
- return EntryInfo(**r.json()[0])
+ files = r.json()
+
+ if not isinstance(files, list) or len(files) == 0:
+ raise Exception("Expected to receive information about written file")
+
+ file = files[0]
+ return EntryInfo(**file)
async def list(
self,
diff --git a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
index ceb68d279..f4b052b64 100644
--- a/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
+++ b/packages/python-sdk/e2b/sandbox_sync/filesystem/filesystem.py
@@ -120,9 +120,13 @@ class Filesystem:
if err:
raise err
- data = r.json()
+ files = r.json()
- return EntryInfo(**data[0])
+ if not isinstance(files, list) or len(files) == 0:
+ raise Exception("Expected to receive information about written file")
+
+ file = files[0]
+ return EntryInfo(**file)
def list(
self,