Repository navigation
bug: TRUNCATE via /v1/query returns HTTP 500 #118
Description
Activity
- addedarea/apiHTTP handlers, routing, middlewareHTTP handlers, routing, middleware
on May 12, 2026 - addedarea/queryStructured query AST, SQL builderStructured query AST, SQL builder
on May 18, 2026 - addedbreaking-changeBreaking change to public API, CLI, or configBreaking change to public API, CLI, or config
on May 18, 2026 Update: evaluate flow and response codes on DELETE, UPDATE, etc, and if we can/should fit into this release, or have them all only be via admin SQL
The 500 error here raised discussion about how should mutation statements like
TRUNCATE,DELETE, andUPDATEbe exposed and authorized. We've settled this in #158: those statements are only valid throughPOST /v1/queryunder anadmin/servicerole (or a policy role withRawSQL: true), and all other pipelined paths that perform them are being removed.Agreeing with the recommendation from the bug report, running
TRUNCATEon an already empty table should succeed (HTTP 200) and return an empty array ([]), just like ClickHouse does. We will include this fix in PR #158. Since #158 makes/v1/querythe single endpoint for these operations, it is the best place to handle the clean formatting of zero-row results.- added a commit that references this issue
on May 20, 2026
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Description
Query endpoint chokes on a no-rows result.
Steps to Reproduce
TRUNCATEon query endpoint, before any events have entered the databaseExpected Behavior
Not sure-- some possible options:
Decision for alpha
Recommend HTTP 200 —
TRUNCATEis idempotent DDL. Running it against an already-empty table is functionally a no-op success; returning 4xx implies the request was bad, which it wasn't. ClickHouse itself returns success on this case. Treat the 500 as a handler bug where a 0-row response shape isn't being marshaled correctly, not as an intentional error.If anyone disagrees, settle before tagging v0.1.0-alpha.1 — the response code is part of the public API surface.
Actual Behavior
Return HTTP 500
Environment
Logs