Skip to content

feat(sdk): less cryptic error if paths are missing for downloadFile#37

Open
robherley wants to merge 2 commits intomainfrom
robherley/extra-validation
Open

feat(sdk): less cryptic error if paths are missing for downloadFile#37
robherley wants to merge 2 commits intomainfrom
robherley/extra-validation

Conversation

@robherley
Copy link

If a user isn't using Typescript, they might accidentally provide the src/dst parameters incorrectly (or forget them):

const sandbox = await Sandbox.create();
await sandbox.writeFiles([
    { path: 'foo.txt', content: 'bar' }
]);
await sandbox.downloadFile({ path: 'foo.txt' }); // missing `dst` argument

And receive an ugly message like:

TypeError: Cannot read properties of undefined (reading 'cwd')
    at DisposableSandbox.downloadFile (/Users/robherley/dev/sandbox-test/node_modules/.pnpm/@vercel+sandbox@1.4.1/node_modules/@vercel/sandbox/dist/sandbox.js:315:53)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)
    at async main (file:///Users/robherley/dev/sandbox-test/index.mjs:9:1)

But now with this change, it's less cryptic:

Error: downloadFile: destination path is required
    at DisposableSandbox.downloadFile (/Users/robherley/vercel/sandbox/packages/vercel-sandbox/dist/sandbox.js:309:19)
    at main (file:///Users/robherley/dev/sandbox-test/index.mjs:8:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:103:5)

@vercel
Copy link

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
sandbox-sdk Building Building Preview Feb 6, 2026 9:34pm
sandbox-sdk-ai-example Ready Ready Preview, Comment Feb 6, 2026 9:34pm

Request Review

@robherley robherley changed the title feat(sdk): more obvious failure if paths are missing for downloadFile feat(sdk): less cryptic error if paths are missing for downloadFile Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant