Repository navigation
[wrangler] fix: normalize CRLF before sending D1 commands to the remote query API - #15044
Conversation
🦋 Changeset detectedLatest commit: 1b7cd77 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
|
CI status: I audited all 22 failing checks. They are unrelated to the D1 change: the failing jobs generate compatibility date The same repository-wide failure is affecting Cloudflare-authored PR #15143 and matches #14942. The focused D1 tests and |
5cef407 to
3bfce39
Compare
The D1 query API splits multi-statement SQL on ';' server-side and mishandles CRLF line endings inside compound statements such as a CREATE TRIGGER ... BEGIN ... END; body, producing 'incomplete input: SQLITE_ERROR'. wrangler d1 migrations apply --remote sends the whole migration (plus the tracking INSERT) as one command string, so CRLF migrations with triggers failed while the same bytes via the import-based execute --remote --file succeeded. Normalize CRLF to LF in the command path before sending. Closes cloudflare#14991.
- Remove the conventional-commit prefix from the changeset title (REVIEW.md forbids type prefixes in changeset titles). - Re-indent the new execute test to the describe nesting level and apply oxfmt so the repository formatting check passes.
3bfce39 to
1b7cd77
Compare
petebacondarwin
left a comment
There was a problem hiding this comment.
Codeowners bypass
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
Fixes #14991
wrangler d1 migrations apply --remotefailed withincomplete input: SQLITE_ERROR [7500]whenever a migration file had CRLF line endings and contained aCREATE TRIGGER ... BEGIN ... END;body — the default situation for Windows checkouts withcore.autocrlf=true.Root cause:
migrations apply --remotesends the whole migration (plus the trackingINSERT) as onesqlstring to the D1/queryendpoint, which splits multi-statement SQL on;server-side and mishandles structural CRLF inside compound statement bodies. The identical bytes succeed viaexecute --remote --filebecause that path uses the D1 import API; the client-side splitter is not involved in the command path.Fix: normalize only structural CRLF before sending commands to the remote query API. The SQL-aware normalizer preserves CRLF inside single-, double-, backtick-, and bracket-quoted content, including doubled quote escapes, so remote execution does not silently change stored values.
Verification: all 16 D1 splitter tests, 16 D1 execute tests, and 33 D1 migration tests pass. The repository-wide
pnpm checkalso passes.Note
This is a contribution from an AI agent: stareezy-1.