Skip to content

Conversation

@langningchen
Copy link

@langningchen langningchen commented Jan 23, 2026

Fixes #7629

Currently, when running wrangler d1 export with a directory path passed to the --output flag, it throws a low-level Node.js EISDIR error. This PR adds a check to verify if the provided output path is a directory and throws a descriptive UserError instead.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
      • Built the project with pnpm run dev.
      • Ran node ./bin/wrangler.js d1 export <db-name> --output ./ (with a dummy wrangler.toml).
      • Confirmed that the error message is now: ✘ [ERROR] Please specify a file path for --output, not a directory.
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: This is a minor improvement to an internal error message and does not change the command's usage or API.
A picture of a cute animal

Furina de Fontaine

Furina de Fontaine is a playable Hydro character in Genshin Impact who can alternate between Pneuma and Ousia alignments.


Open with Devin

@langningchen langningchen requested review from a team as code owners January 23, 2026 14:10
Copilot AI review requested due to automatic review settings January 23, 2026 14:10
@changeset-bot
Copy link

changeset-bot bot commented Jan 23, 2026

🦋 Changeset detected

Latest 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

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View issue and 1 additional flag in Devin Review.

Open in Devin Review

Copy link
Contributor

Copilot AI left a 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 --output path check intended to detect directory paths and throw a descriptive UserError.
  • 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.

Comment on lines +85 to +90
try {
const stats = await fs.stat(output);
if (stats.isDirectory()) {
throw new UserError(
`Please specify a file path for --output, not a directory.`
);
Copy link

Copilot AI Jan 23, 2026

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).

Copilot uses AI. Check for mistakes.
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.

🐛 BUG: D1 export throws cryptic error when passed directory instead of file

1 participant