Skip to content

fix(wrangler): show friendly error when D1 export output is a directory#12065

Merged
edmundhung merged 11 commits intocloudflare:mainfrom
langningchen:langningchen/d1-export-message
Feb 2, 2026
Merged

fix(wrangler): show friendly error when D1 export output is a directory#12065
edmundhung merged 11 commits intocloudflare:mainfrom
langningchen:langningchen/d1-export-message

Conversation

@langningchen
Copy link
Copy Markdown
Contributor

@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:
    • 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
Copy Markdown

changeset-bot Bot commented Jan 23, 2026

🦋 Changeset detected

Latest commit: 76d8846

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
Copy Markdown
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

Comment thread packages/wrangler/src/d1/export.ts Outdated
Copy link
Copy Markdown
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 thread packages/wrangler/src/d1/export.ts Outdated
Comment thread packages/wrangler/src/d1/export.ts Outdated
Copy link
Copy Markdown
Member

@edmundhung edmundhung left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! This should be testable. Take a look at packages/wrangler/src/tests/d1/ for examples of how D1 commands are tested. A test that verifies the error when --output is a directory would be a good addition. :)

Comment thread .changeset/cute-pets-fry.md Outdated
Comment thread packages/wrangler/src/d1/export.ts Outdated
Comment thread packages/wrangler/src/d1/export.ts Outdated
Copy link
Copy Markdown
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

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/wrangler/src/d1/export.ts Outdated
Comment thread .changeset/cute-pets-fry.md
@langningchen
Copy link
Copy Markdown
Contributor Author

@edmundhung Thanks for the feedback! I've updated the code to use statSync with throwIfNoEntry and added a test case in export.test.ts to cover this scenario. Local tests are now passing. Ready for another look!

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Jan 29, 2026

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@12065

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@12065

miniflare

npm i https://pkg.pr.new/miniflare@12065

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@12065

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@12065

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@12065

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@12065

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@12065

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@12065

wrangler

npm i https://pkg.pr.new/wrangler@12065

commit: 76d8846

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jan 29, 2026
@edmundhung edmundhung enabled auto-merge January 29, 2026 14:09
@edmundhung edmundhung added this pull request to the merge queue Jan 29, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 29, 2026
@edmundhung edmundhung added this pull request to the merge queue Jan 29, 2026
@penalosa penalosa removed this pull request from the merge queue due to the queue being cleared Jan 29, 2026
@langningchen
Copy link
Copy Markdown
Contributor Author

Hi @edmundhung, sorry to bother you. I've updated the branch to keep it in sync with main. It seems the CI workflows are awaiting approval to run. Whenever you have a moment, could you please trigger them? Thanks!

@edmundhung edmundhung merged commit 47944d1 into cloudflare:main Feb 2, 2026
37 of 38 checks passed
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Feb 2, 2026
@langningchen langningchen deleted the langningchen/d1-export-message branch February 3, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

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

4 participants