-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix(wrangler): show friendly error when D1 export output is a directory #12065
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
fix(wrangler): show friendly error when D1 export output is a directory #12065
Conversation
🦋 Changeset detectedLatest commit: 7d47f29 The changes in this PR will be included in the next version bump. 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Improves wrangler d1 export by replacing a low-level Node.js EISDIR error with a friendlier UserError when --output points to a directory.
Changes:
- Added a preflight
--outputpath check intended to detect directory paths and throw a descriptiveUserError. - Updated a comment spelling in the local export implementation.
- Added a changeset for a patch release of
wrangler.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/wrangler/src/d1/export.ts | Adds --output directory detection to produce a friendly error message before attempting to write. |
| .changeset/cute-pets-fry.md | Records the user-facing change in a patch changeset. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| try { | ||
| const stats = await fs.stat(output); | ||
| if (stats.isDirectory()) { | ||
| throw new UserError( | ||
| `Please specify a file path for --output, not a directory.` | ||
| ); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are existing automated tests for wrangler d1 export (e.g. packages/wrangler/src/__tests__/d1/export.test.ts), so this new directory-validation behavior should be covered with a test (create a directory, pass it as --output, and assert the friendly UserError message).
Fixes #7629
Currently, when running
wrangler d1 exportwith a directory path passed to the--outputflag, it throws a low-level Node.jsEISDIRerror. This PR adds a check to verify if the provided output path is a directory and throws a descriptiveUserErrorinstead.pnpm run dev.node ./bin/wrangler.js d1 export <db-name> --output ./(with a dummy wrangler.toml).✘ [ERROR] Please specify a file path for --output, not a directory.A picture of a cute animal