Skip to content

armgit / E2B

Public Imported from GitHub
0

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

allow passing empty array of files in js-sdk

0div2afb6d1ef461
diff --git a/packages/js-sdk/src/sandbox/filesystem/index.ts b/packages/js-sdk/src/sandbox/filesystem/index.ts
index b4b06a44c..f805c5d4a 100644
--- a/packages/js-sdk/src/sandbox/filesystem/index.ts
+++ b/packages/js-sdk/src/sandbox/filesystem/index.ts
@@ -171,7 +171,7 @@ export class Filesystem {
}
const files = res.data
- if (!files || files.length === 0) {
+ if (!files) {
throw new Error('Expected to receive information about written file')
}
diff --git a/packages/js-sdk/tests/sandbox/files/write.test.ts b/packages/js-sdk/tests/sandbox/files/write.test.ts
index 1ad4249da..2aa82d1e0 100644
--- a/packages/js-sdk/tests/sandbox/files/write.test.ts
+++ b/packages/js-sdk/tests/sandbox/files/write.test.ts
@@ -23,18 +23,13 @@ sandboxTest('write file', async ({ sandbox }) => {
sandboxTest('write multiple files', async ({ sandbox }) => {
// Attempt to write with empty files array
- await sandbox.files
- .write([])
- .then((e) => {
- assert.isUndefined(e)
- })
- .catch((err) => {
- assert.instanceOf(err, Error)
- assert.include(err.message, 'Expected to receive information about written file')
- })
+ const emptyInfo = await sandbox.files.write([])
+ assert.isTrue(Array.isArray(emptyInfo))
+ assert.equal(emptyInfo.length, 0)
// Attempt to write with path and file array
await sandbox.files
+ // @ts-ignore
.write('/path/to/file', [{ path: 'one_test_file.txt', data: 'This is a test file.' }])
.then((e) => {
assert.isUndefined(e)