{"record":{"id":"cfdb20b7c31849a3","repo":"tursodatabase/turso","slug":"remote-sql-execution-failed-value","errorCode":null,"errorMessage":"remote sql execution failed: {value}","messagePattern":"remote sql execution failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"bindings/rust/src/sync.rs","lineNumber":1300,"sourceCode":"            let resp = self\n                .client\n                .post(format!(\"{}{}/v2/pipeline\", self.user_url, self.db_prefix))\n                .header(\"Host\", &self.host)\n                .json(&json!({\n                    \"requests\": [{\n                        \"type\": \"execute\",\n                        \"stmt\": { \"sql\": sql }\n                    }]\n                }))\n                .send()\n                .await?\n                .error_for_status()?;\n\n            let value: serde_json::Value = resp.json().await?;\n\n            let result = &value[\"results\"][0];\n            if result[\"type\"] != \"ok\" {\n                return Err(anyhow!(\"remote sql execution failed: {value}\"));\n            }\n\n            let rows = result[\"response\"][\"result\"][\"rows\"]\n                .as_array()\n                .ok_or_else(|| anyhow!(\"invalid response shape\"))?;\n\n            Ok(rows\n                .iter()\n                .map(|row| {\n                    row.as_array()\n                        .unwrap()\n                        .iter()\n                        .map(|cell| match cell[\"value\"].clone() {\n                            serde_json::Value::Null => Value::Null,\n                            serde_json::Value::Number(number) => {\n                                if number.is_i64() {\n                                    Value::Integer(number.as_i64().unwrap())\n                                } else {","sourceCodeStart":1282,"sourceCodeEnd":1318,"githubUrl":"https://github.com/tursodatabase/turso/blob/492c4a71cd7c2649e7df83da1471b74f4b1c7aa9/bindings/rust/src/sync.rs#L1282-L1318","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet rows = server.db_sql(\"SELECT * FORM t\").await?; // typo: FORM\n// after\nlet rows = server.db_sql(\"SELECT * FROM t\").await?;","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match server.db_sql(sql).await {\n    Ok(rows) => rows,\n    Err(e) => {\n        eprintln!(\"db_sql failed for [{sql}]: {e}\");\n        return Err(e);\n    }\n}","preventionTips":["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"],"tags":["sync","test-harness","sql","hrana","json-api","rust"],"backgroundTag":"sql-execution-error","analyzedSha":"492c4a71cd7c2649e7df83da1471b74f4b1c7aa9","analyzedAt":"2026-08-20T07:02:18.389Z","contentChangedAt":"2026-08-20T07:02:18.389Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}