You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
D1 /query rejects LF-only multi-statement SQL ending in an uppercase-BEGIN trigger #113
Send one documented { "sql": "..." } request to D1 /query containing six CREATE TABLE statements followed by one multiline trigger. This sanitized example shows the relevant shape without application names or columns:
CREATETABLEitem_1 (id INTEGERPRIMARY KEY, value TEXT);
CREATETABLEitem_2 (id INTEGERPRIMARY KEY);
CREATETABLEitem_3 (id INTEGERPRIMARY KEY);
CREATETABLEitem_4 (id INTEGERPRIMARY KEY);
CREATETABLEitem_5 (id INTEGERPRIMARY KEY);
CREATETABLEitem_6 (id INTEGERPRIMARY KEY);
CREATETRIGGERitem_1_after_insert
AFTER INSERT ON item_1
BEGINUPDATE item_1 SET value = value WHERE id =NEW.id;
END;
The observed request used the same shape with six tables and one unchanged multiline trigger. It was LF-only (zero CR bytes), used uppercase BEGIN, and was submitted in one OpenAPI-supported {sql} request. The generic SQL above is a redaction, not a claim that those exact bytes were separately tested remotely.
Observed: local SQLite accepted the SQL and created all seven objects. Remote /query returned HTTP 400, code 7500, incomplete input: SQLITE_ERROR; a follow-up query found the remote schema empty.
Expected:/query accepts the valid multi-statement SQL and creates the six tables and trigger.
A semantically equivalent single-line trigger succeeds locally, but it had not been tested remotely when this report was filed.
Versions and scope
Alchemy 2.0.0-beta.77 produced the joined SQL; Wrangler was not involved in the failing request.
The request went directly through the public D1 REST contract.
Could the D1 team confirm whether the server-side /query splitter is expected to accept a multi-statement string whose final statement is a multiline trigger? Is there another token or statement-boundary condition maintainers would like isolated in a further sanitized reproduction?
This report was generated with AI assistance and approved by a human.
D1 REST /query returns HTTP 400 code 7500 incomplete input: SQLITE_ERROR for LF-only multi-statement SQL (six CREATE TABLEs plus one multiline uppercase-BEGIN trigger) that local SQLite accepts; sanitized example was not remotely verified and single-line variant untested remotely.
Reproduction reason: Report describes a concrete current-behavior defect with a testable SQL shape (LF-only multi-statement string ending in an uppercase-BEGIN multiline trigger) and an observed HTTP 400 incomplete-input error; no suspicious or redirecting content.
Missing information:
minimal reproduction
Reproduction
Result:⚠️ Blocked.
Summary: Blocked: the reported HTTP 400 (code 7500) is produced by the remote D1 REST /query endpoint, which requires Cloudflare credentials absent from this sandbox. Local splitter and local /query paths accept the reported SQL; local exec() fails with the exact reported error on the reported shape.
Evidence and attempted steps
Steps attempted:
Cloned cloudflare/workers-sdk at HEAD 2298cf1 and built all packages per the documented setup (pnpm install --frozen-lockfile and pnpm build; 41/41 turbo tasks OK).
Ran the in-repo wrangler D1 splitter (packages/wrangler/src/d1/splitter.ts) on the reported fixture: 7 complete statements, final multiline uppercase-BEGIN trigger intact - no local splitter defect.
Exercised the local D1 POST /query handler via the miniflare D1 binding with the joined sql string: accepted, sqlite_master lists 6 tables plus trigger; matches the issue's local observation.
Command: node d1-e2e.mjs fixture.sql (db.prepare(joined).all() sends the joined sql to local POST /query)
Isolated fresh-database run of the exact wrangler d1 execute --local path: splitSqlQuery yields 7 statements, db.batch all success, all 7 objects created.
Command: node d1-isolated-batch.mjs fixture.sql
Variant matrix on the local workerd D1 exec() API (fresh DB per case): tables-only SUCCESS; single-line trigger SUCCESS; reported multiline-trigger shape ERROR 'incomplete input: SQLITE_ERROR' (exact issue error string).
Command: node d1-exec-matrix.mjs
Documented CLI path: wrangler d1 execute repro-db --local --file=fixture.sql exit 0; verification query listed the six tables and the trigger.
Command: wrangler d1 execute repro-db --local --file=fixture.sql && wrangler d1 execute repro-db --local --command "SELECT type, name FROM sqlite_master"
Attempted the reported remote surface via the built wrangler CLI to document the credential gate: --remote --file exits 1 requiring CLOUDFLARE_API_TOKEN; the remote POST /query was never sent. Also packaged a standalone pinned project (pnpm reproduce, exit 0) repeating the local checks.
Blocker: The reported behavior (HTTP 400, code 7500, 'incomplete input: SQLITE_ERROR') is produced by the remote Cloudflare D1 REST endpoint POST /accounts/(account_id)/d1/database/(id)/query. Exercising it requires a Cloudflare account ID and API token (e.g. CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID), which do not exist in this sandbox and which must not be requested or searched for; the built wrangler CLI confirms the gate (exit 1: 'In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work.'), so the decisive remote request was never sent.
We independently hit a very similar failure with Wrangler 4.92.0 on macOS against an EU D1 database. The Node version was not recorded in the retained run evidence.
wrangler d1 migrations apply --remote returned:
incomplete input: SQLITE_ERROR [code: 7500]
Our migration has 3 tables, 3 unique indexes and 9 triggers: 3 multiline and 6 single-line. All trigger BEGIN/END keywords are uppercase. The 6,989-byte file is LF-only, with no BOM, NUL or non-ASCII bytes.
One potentially useful difference from #113: the multiline triggers are earlier in the migration. Its last statement is a single-line trigger, then Wrangler appends its migration-ledger INSERT. The combined request therefore ends with an INSERT, not a trigger. Source-based reconstruction gives 7,092 SQL bytes in one sql field, or 7,265 JSON bytes; this is not a captured wire body.
The installed local path splits statements before executing a batch; the remote path sends the combined SQL string to /query without that client-side split. Local isolation passed 533 cases in each of three paths, including all 511 nonempty trigger combinations. The ledger append also passed locally.
Post-failure readbacks found identical schema and unchanged migration ledger, no partial objects, zero FK violations and quick_check = ok. This is observed no-change behavior, not proof of general rollback guarantees.
This looks strongly related, but we have not proved a shared root cause or obtained a minimal remote reproduction. Would the trailing ledger INSERT help narrow down the server-side parsing path? We can provide additional sanitized structural evidence if useful.
We have a similar error, but our client execution path differs from the original report in #113:
Original report: Alchemy submits a SQL string directly to the D1 REST /query endpoint; Wrangler was not involved.
Our case: the standard wrangler d1 migrations apply --remote command, with Wrangler pinned to 4.92.0, on macOS with Node.js 24.19.0.
Our remote attempt exited with code 1 and D1 API error 7500 / incomplete input. Prior local standard-migration validation of the same private migration succeeded.
Relevant differences and observations:
Our SQL is LF-only, with no CR, BOM or NUL bytes, and uppercase BEGIN/END.
All trigger bodies in the latest remotely attempted SQL were already single-line. A whitespace-only adjustment had not resolved the failure.
Our migration file ends with a non-trigger statement. Inspection of the installed Wrangler source indicates that its migration-ledger INSERT is appended to the SQL sent through the remote query path. This is a source-based observation, not a captured wire request.
Authentication and read-only target checks succeeded immediately before the attempt.
Read-only inspection after the failure found only the empty d1_migrations table: no application tables or triggers, and no applied-migration record. This is an observed result, not proof of a general rollback guarantee.
We have not established whether this shares the root cause of #113.
Anonymous local test candidate
The following SQL uses only generic names. It is not a confirmed minimal remote reproducer:
CREATETABLEdemo_alpha(id INTEGERPRIMARY KEY, amount INTEGERNOT NULL DEFAULT 0);
CREATETABLEdemo_beta(id INTEGERPRIMARY KEY, source_id INTEGERNOT NULLREFERENCES demo_alpha(id));
CREATEINDEXdemo_beta_sourceON demo_beta(source_id);
CREATETRIGGERdemo_alpha_created AFTER INSERT ON demo_alpha
BEGININSERT INTO demo_beta(id,source_id) VALUES(NEW.id,NEW.id);
UPDATE demo_alpha SET amount=amount+1WHERE id=NEW.id;
END;
This exact generic candidate succeeded locally with SQLite, the installed Wrangler 4.92.0 splitter plus a local D1 Binding API batch, and wrangler d1 execute --local --file.
A separate line-oriented local D1 exec() test rejected the multiline candidate and accepted its single-line equivalent. That uses a different API and does not establish the cause of the remote /query failure.
The generic candidate has not been executed against remote D1. The confirmed remote 7500 belongs to our private application migration. The local standard-migration success above also refers to that private migration; we are not claiming a standard-migration or remote test of this generic candidate.
Questions
Could the standard Wrangler migration failure be related to the remote parsing problem reported here, despite the single-line triggers and trailing ledger INSERT? What further sanitized evidence would help distinguish this from other causes of error 7500?
What officially supported workaround or confirmed fixed Wrangler version do you recommend? Would separating table/index creation and trigger creation into separate standard migrations help, or is another supported path required?
What atomicity and rollback guarantees apply to the schema changes and d1_migrations entry within one migration? With separate migrations, how should we verify the committed state and safely resume after a later phase fails? If you recommend an import path, how should migration bookkeeping and recovery be preserved?
We have stopped remote write attempts. We can provide further sanitized observations, but cannot publish private application SQL, account/database identifiers, customer information, credentials or raw logs.
We ran into the same class of local-SQLite-passes vs remote-D1-/query-fails migration bugs (triggers with BEGIN ... END;, explicit BEGIN TRANSACTION blocks, and unguarded FOREIGN KEY DDL) and built an offline pre-flight linter for migrations/*.sql in wrangler-doctor:
Running npx wrangler-doctor in CI flags trigger bodies (WD202), explicit transaction statements rejected by remote D1 (WD201), and schema mutations that behave differently between local Miniflare SQLite and the remote D1 /query endpoint before deployment.
Activity
workers-devprod commentedon Sep 17, 2026
Automated triage
Issue assessment
product:d1(high)api(medium)Actionability and missing information
D1 REST /query returns HTTP 400 code 7500 incomplete input: SQLITE_ERROR for LF-only multi-statement SQL (six CREATE TABLEs plus one multiline uppercase-BEGIN trigger) that local SQLite accepts; sanitized example was not remotely verified and single-line variant untested remotely.
Reproduction reason: Report describes a concrete current-behavior defect with a testable SQL shape (LF-only multi-statement string ending in an uppercase-BEGIN multiline trigger) and an observed HTTP 400 incomplete-input error; no suspicious or redirecting content.
Missing information:
Reproduction
Evidence and attempted steps
Steps attempted:
git clone https://github.com/cloudflare/workers-sdk.git && cd workers-sdk && pnpm install --frozen-lockfile && pnpm buildesbuild packages/wrangler/src/d1/splitter.ts --bundle --format=cjs --platform=node --outfile=splitter-bundle.cjs && node test-splitter.cjs fixture.sqlnode d1-e2e.mjs fixture.sql (db.prepare(joined).all() sends the joined sql to local POST /query)node d1-isolated-batch.mjs fixture.sqlnode d1-exec-matrix.mjswrangler d1 execute repro-db --local --file=fixture.sql && wrangler d1 execute repro-db --local --command "SELECT type, name FROM sqlite_master"wrangler d1 execute repro-db --remote --file=fixture.sql ; cd reproduction-output/project && pnpm install && pnpm reproduceBlocker: The reported behavior (HTTP 400, code 7500, 'incomplete input: SQLITE_ERROR') is produced by the remote Cloudflare D1 REST endpoint POST /accounts/(account_id)/d1/database/(id)/query. Exercising it requires a Cloudflare account ID and API token (e.g. CLOUDFLARE_API_TOKEN/CLOUDFLARE_ACCOUNT_ID), which do not exist in this sandbox and which must not be requested or searched for; the built wrangler CLI confirms the gate (exit 1: 'In a non-interactive environment, it's necessary to set a CLOUDFLARE_API_TOKEN environment variable for wrangler to work.'), so the decisive remote request was never sent.
Artifact: Download reproduction archive (Cloudflare Access required).
This summary was generated by an LLM and may contain errors. Please verify its findings.
Triage bot commands and options
Repository collaborators with write or admin access can trigger actions by commenting on this issue:
@workers-devprod reproduce: Attempt to reproduce the issue using its description and recent comments.pokeracetom commentedon Oct 10, 2026
We independently hit a very similar failure with Wrangler 4.92.0 on macOS against an EU D1 database. The Node version was not recorded in the retained run evidence.
wrangler d1 migrations apply --remotereturned:incomplete input: SQLITE_ERROR [code: 7500]Our migration has 3 tables, 3 unique indexes and 9 triggers: 3 multiline and 6 single-line. All trigger
BEGIN/ENDkeywords are uppercase. The 6,989-byte file is LF-only, with no BOM, NUL or non-ASCII bytes.One potentially useful difference from #113: the multiline triggers are earlier in the migration. Its last statement is a single-line trigger, then Wrangler appends its migration-ledger INSERT. The combined request therefore ends with an INSERT, not a trigger. Source-based reconstruction gives 7,092 SQL bytes in one
sqlfield, or 7,265 JSON bytes; this is not a captured wire body.The installed local path splits statements before executing a batch; the remote path sends the combined SQL string to
/querywithout that client-side split. Local isolation passed 533 cases in each of three paths, including all 511 nonempty trigger combinations. The ledger append also passed locally.Post-failure readbacks found identical schema and unchanged migration ledger, no partial objects, zero FK violations and
quick_check = ok. This is observed no-change behavior, not proof of general rollback guarantees.This looks strongly related, but we have not proved a shared root cause or obtained a minimal remote reproduction. Would the trailing ledger INSERT help narrow down the server-side parsing path? We can provide additional sanitized structural evidence if useful.
evolvehiroyuki-hub commentedon Oct 15, 2026
Hello Cloudflare team,
We have a similar error, but our client execution path differs from the original report in #113:
/queryendpoint; Wrangler was not involved.wrangler d1 migrations apply --remotecommand, with Wrangler pinned to 4.92.0, on macOS with Node.js 24.19.0.Our remote attempt exited with code 1 and D1 API error 7500 /
incomplete input. Prior local standard-migration validation of the same private migration succeeded.Relevant differences and observations:
BEGIN/END.d1_migrationstable: no application tables or triggers, and no applied-migration record. This is an observed result, not proof of a general rollback guarantee.We have not established whether this shares the root cause of #113.
Anonymous local test candidate
The following SQL uses only generic names. It is not a confirmed minimal remote reproducer:
This exact generic candidate succeeded locally with SQLite, the installed Wrangler 4.92.0 splitter plus a local D1 Binding API batch, and
wrangler d1 execute --local --file.A separate line-oriented local D1
exec()test rejected the multiline candidate and accepted its single-line equivalent. That uses a different API and does not establish the cause of the remote/queryfailure.The generic candidate has not been executed against remote D1. The confirmed remote 7500 belongs to our private application migration. The local standard-migration success above also refers to that private migration; we are not claiming a standard-migration or remote test of this generic candidate.
Questions
d1_migrationsentry within one migration? With separate migrations, how should we verify the committed state and safely resume after a later phase fails? If you recommend an import path, how should migration bookkeeping and recovery be preserved?We have stopped remote write attempts. We can provide further sanitized observations, but cannot publish private application SQL, account/database identifiers, customer information, credentials or raw logs.
Thank you.
kanchingyg commentedon Oct 25, 2026
We ran into the same class of local-SQLite-passes vs remote-D1-
/query-fails migration bugs (triggers withBEGIN ... END;, explicitBEGIN TRANSACTIONblocks, and unguardedFOREIGN KEYDDL) and built an offline pre-flight linter formigrations/*.sqlinwrangler-doctor:npx wrangler-doctor # Checks migrations/*.sql for D1 remote /query splitter & execution hazards (WD201-WD206)Running
npx wrangler-doctorin CI flags trigger bodies (WD202), explicit transaction statements rejected by remote D1 (WD201), and schema mutations that behave differently between local Miniflare SQLite and the remote D1/queryendpoint before deployment.