cloudflare / cloudflare/developer-platform

Errors when running sqlite files with D1 are very unhelpful

Open
#13 3 comments 0 reactions 0 assignees View on GitHub
product:d1
Dominant language
No language data
Stars
1
Forks
0
PR merge metrics
No merged PRs in 30d

Description

### What versions & operating system are you using?

wrangler 4.26.0, macos

### Please provide a link to a minimal reproduction

_No response_

### Describe the Bug

Here's the output I see now when I have a simple bug in my sql syntax

```
0 ➤ npx wrangler@latest d1 execute pydantic-test --local --file=schema.sql

⛅️ wrangler 4.26.0
───────────────────
🌀 Executing on local database pydantic-test (test) from .wrangler/state/v3/d1:
🌀 To execute on your remote database, add a --remote flag to your wrangler command.

✘ [ERROR] near "limit": syntax error at offset 205: SQLITE_ERROR

If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
? Would you like to report this error to Cloudflare? Wrangler's output and the error details will be shared with the Wrangler team to help us diagnose and fix the issue. › (Y/n)
```

1. The error gives an offset, not a line number
2. The offset is relative the expression, not the file - making it almost impossible to use!
3. The incorrect code is not show
4. You're constantly suggesting I create issues when I just have an error in my sql syntax

Compare this to the error I get from sqlite:

```
➤ sqlite3 test.edb < schema.sql
Parse error near line 77: near "limit": syntax error
lete old usage beyond one month CHECK (usage <= limit) );
error here ---^
```

### Please provide any relevant error logs

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `npx wrangler@latest d1 execute ... --local --file=schema.sql` with the malformed SQL described, then compare its output with the sqlite3 example. Trace the command's local D1 error reporting entry point; done means syntax errors identify the file-relative line, show the relevant SQL context, and avoid the issue-report prompt.

Written by the indexing model from the issue text.

Assessment

Tech stack
sql, sqlite
Domain
cli, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.