Skip to content
← Back to activity

Immutable solution version

Server returned HTTP status 400: SQL text 0 not found

Version 2Sign in to save

Complete solution

Libsql Client Ts: server returned HTTP status 400: SQL text 0 not found. The verified fix is Workaround at the time: libsql-stateless-easy (stateless batching). Use this when you hit the symptoms above in libsql-client-ts; not for unrelated libsql-client-ts errors or general setup questions.

TL;DR

Workaround at the time: libsql-stateless-easy (stateless batching).

The error

Issue tursodatabase/libsql-client-ts#177 (closed, 5 comments): Hello! I get the following error `Server returned HTTP status 400: SQL text 0 not found`. This happens when batch inserting 50 rows, if I shrink this array everything works fine.
Failed (batch, 50 rows):

Fix

  1. Workaround at the time: libsql-stateless-easy (stateless batching).

Success check: the symptom above is gone and the original operation completes.

When to use

  • You hit this exact symptom in libsql-client-ts.
  • You want the verified fix without digging through the thread.

When not to use

  • A different error in libsql-client-ts, even a similar-looking one.
  • General libsql-client-ts setup or credential questions.

Compatibility

  • Libsql Client Ts (tursodatabase/libsql-client-ts)

Variant phrasings

  • How to fix "server returned HTTP status 400: SQL text 0 not found" in libsql-client-ts
  • libsql-client-ts: server returned HTTP status 400: SQL text 0 not found

Root cause

[invisal (commenter), root cause found via Discord discussion]: The client's batch() stores statements server-side via stored_sql, which Turso/sqld limits to ~5KB - so larger batches fail with Server returned HTTP status 400: SQL text 0 not found.

Source

  • https://github.com/tursodatabase/libsql-client-ts/issues/177

Evidence

Asked in gh:tursodatabase/libsql-client-ts#177 (https://github.com/tursodatabase/libsql-client-ts/issues/177): Server returned HTTP status 400: SQL text 0 not found. The issue report: Issue tursodatabase/libsql-client-ts#177 (closed, 5 comments): Hello! I get the following error Server returned HTTP status 400: SQL text 0 not found. This happens when batch inserting 50 rows, if I shrink this array everything works fine.

sqld sqld 0.22.14 (2931e2b5 2024-01-18)
"@libsql/client": "^0.4.3",
import { createClient } from "@libsql/client"
export const sqlite = createClient({ url: dbUrl })

Failed (batch, 50 rows):

    sqlite.batch([`
    INSERT INTO asset (fingerprint, policy_id, asset_name, ref_fingerprint, quantity)
        VALUES
          ('asset100kvrdjjqk4dasq8l8mjv6kmm9gvphv6wq3d32','b863bc73 The verified answer: [invisal (commenter), root cause found via Discord discussion]: The client's batch() stores statements server-side via `stored_sql`, which Turso/sqld limits to ~5KB  -  so larger batches fail with `Server returned HTTP status 400: SQL text 0 not found`. The client had no way to opt out of stored_sql for batches. Workaround at the time: libsql-stateless-easy (stateless batching). (No maintainer fix stated in the thread.)

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_dSlgBNVkgUHIvTcHa0qujA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Server returned HTTP status 400: SQL text 0 not found <span>— Vectle</span></a>

Server returned HTTP status 400: SQL text 0 not found | Vectle