From 939f9ce3ca036dd09e38bbcac771e74321404865 Mon Sep 17 00:00:00 2001 From: Langning Chen Date: Fri, 23 Jan 2026 21:35:47 +0800 Subject: [PATCH 1/3] fix(export): correct spelling --- packages/wrangler/src/d1/export.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/wrangler/src/d1/export.ts b/packages/wrangler/src/d1/export.ts index af52c2e0b612..bec399b84113 100644 --- a/packages/wrangler/src/d1/export.ts +++ b/packages/wrangler/src/d1/export.ts @@ -114,7 +114,7 @@ async function exportLocal( const id = localDB.previewDatabaseUuid ?? localDB.uuid; - // TODO: should we allow customising persistence path? + // TODO: should we allow customizing persistence path? // Should it be --persist-to for consistency (even though this isn't persisting anything)? const persistencePath = getLocalPersistencePath(undefined, config); const d1Persist = path.join(persistencePath, "v3", "d1"); From cd5a26f7f7cf642963f256e7baafbb2dec7e6cbb Mon Sep 17 00:00:00 2001 From: Langning Chen Date: Fri, 23 Jan 2026 22:00:34 +0800 Subject: [PATCH 2/3] fix(wrangler): validate output path to ensure it's a file, not a directory --- .changeset/cute-pets-fry.md | 5 +++++ packages/wrangler/src/d1/export.ts | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 .changeset/cute-pets-fry.md diff --git a/.changeset/cute-pets-fry.md b/.changeset/cute-pets-fry.md new file mode 100644 index 000000000000..18c12e3519a2 --- /dev/null +++ b/.changeset/cute-pets-fry.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +Added friendly error message when D1 export output is a directory diff --git a/packages/wrangler/src/d1/export.ts b/packages/wrangler/src/d1/export.ts index bec399b84113..643067ddef57 100644 --- a/packages/wrangler/src/d1/export.ts +++ b/packages/wrangler/src/d1/export.ts @@ -82,6 +82,15 @@ export const d1ExportCommand = createCommand({ throw new UserError(`You cannot specify both --no-schema and --no-data`); } + try { + const stats = await fs.stat(output); + if (stats.isDirectory()) { + throw new UserError( + `Please specify a file path for --output, not a directory.` + ); + } + } catch {} + // Allow multiple --table x --table y flags or none const tables: string[] = table ? Array.isArray(table) From 7d47f2994aaf35d9e70afba1fc3604b8bec2491f Mon Sep 17 00:00:00 2001 From: Langning Chen Date: Fri, 23 Jan 2026 22:13:15 +0800 Subject: [PATCH 3/3] fix(export): improve error handling for output path validation --- packages/wrangler/src/d1/export.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/wrangler/src/d1/export.ts b/packages/wrangler/src/d1/export.ts index 643067ddef57..bd8c1fdfb999 100644 --- a/packages/wrangler/src/d1/export.ts +++ b/packages/wrangler/src/d1/export.ts @@ -89,7 +89,11 @@ export const d1ExportCommand = createCommand({ `Please specify a file path for --output, not a directory.` ); } - } catch {} + } catch (e) { + if (e instanceof UserError) { + throw e; + } + } // Allow multiple --table x --table y flags or none const tables: string[] = table