tursodatabase/turso · error · anyhow::Error
remote sql execution failed: {value}
Error message
remote sql execution failed: {value} What it means
Thrown by TursoServer::db_sql when the sync server's JSON response reports a non-ok result for the executed statement. The harness POSTs a Hrana-style batch with {"type":"execute","stmt":{"sql":...}} and checks that results[0].type equals "ok"; on failure the entire response JSON is embedded in the error (bindings/rust/src/sync.rs:1203), so the server's own error text is visible.
Source
Thrown at bindings/rust/src/sync.rs:1300
let resp = self
.client
.post(format!("{}{}/v2/pipeline", self.user_url, self.db_prefix))
.header("Host", &self.host)
.json(&json!({
"requests": [{
"type": "execute",
"stmt": { "sql": sql }
}]
}))
.send()
.await?
.error_for_status()?;
let value: serde_json::Value = resp.json().await?;
let result = &value["results"][0];
if result["type"] != "ok" {
return Err(anyhow!("remote sql execution failed: {value}"));
}
let rows = result["response"]["result"]["rows"]
.as_array()
.ok_or_else(|| anyhow!("invalid response shape"))?;
Ok(rows
.iter()
.map(|row| {
row.as_array()
.unwrap()
.iter()
.map(|cell| match cell["value"].clone() {
serde_json::Value::Null => Value::Null,
serde_json::Value::Number(number) => {
if number.is_i64() {
Value::Integer(number.as_i64().unwrap())
} else {View on GitHub (pinned to 492c4a71cd)
Solutions
- Read the embedded JSON - the server's error field names the exact SQL problem
- Print the sql string passed to db_sql and run it manually against the server
- Ensure setup statements (CREATE TABLE / INSERT) completed before the failing query
- If the server error mentions busy/locked, sequence or retry concurrent db_sql calls
Example fix
// before
let rows = server.db_sql("SELECT * FORM t").await?; // typo: FORM
// after
let rows = server.db_sql("SELECT * FROM t").await?; Defensive patterns
Strategy: try-catch
Try / catch
match server.db_sql(sql).await {
Ok(rows) => rows,
Err(e) => {
eprintln!("db_sql failed for [{sql}]: {e}");
return Err(e);
}
} Prevention
- Run setup DDL and assert it succeeded before querying through db_sql
- Keep SQL string constants near their schema definitions to avoid drift
- Read the embedded response JSON - it contains the server's own error message
When it happens
Trigger: Executing invalid SQL through db_sql (syntax error, no such table, constraint violation); SELECTing a table the test has not created yet; server-side execution errors while applying the statement.
Common situations: Test ordering assumptions (query before CREATE/INSERT completes); typos in table or column names in test SQL; schema drift between what the test writes and what the server has.
Related errors
- request failed: {status} {text}
- local sync server on port {port} did not become ready within
- local sync server failed to start after {SPAWN_ATTEMPTS} att
- invalid response shape
- Error querying database: {}
AI-assisted analysis of tursodatabase/turso@492c4a71cd (2026-08-20).
Data as JSON: /api/errors/cfdb20b7c31849a3.
Report an issue: GitHub.