{"record":{"id":"1221144b4ac681ee","repo":"linera-io/linera-protocol","slug":"query-failed","errorCode":null,"errorMessage":"Query \"{}\" failed: {}","messagePattern":"Query \"(.+?)\" failed: (.+?)","errorType":"exception","errorClass":"anyhow","httpStatus":null,"severity":"error","filePath":"linera-service/src/cli_wrappers/wallet.rs","lineNumber":2234,"sourceCode":"                }\n                Err(error) => {\n                    let query = truncate_query_output_serialize(&query);\n                    return Err(error)\n                        .with_context(|| format!(\"run_json_query: failed to post query={query}\"));\n                }\n            };\n            ensure!(\n                response.status().is_success(),\n                \"Query \\\"{}\\\" failed: {}\",\n                truncate_query_output_serialize(&query),\n                response\n                    .text()\n                    .await\n                    .unwrap_or_else(|error| format!(\"Could not get response text: {error}\"))\n            );\n            let value: Value = response.json().await.context(\"invalid JSON\")?;\n            if let Some(errors) = value.get(\"errors\") {\n                bail!(\n                    \"Query \\\"{}\\\" failed: {}\",\n                    truncate_query_output_serialize(&query),\n                    errors\n                );\n            }\n            return Ok(value);\n        }\n        unreachable!()\n    }\n\n    /// Runs the given string as a GraphQL query, wrapping it in `query { ... }`.\n    pub async fn query(&self, query: impl AsRef<str>) -> Result<Value> {\n        let query = query.as_ref();\n        self.run_graphql_query(&format!(\"query {{ {query} }}\"))\n            .await\n    }\n\n    /// Runs the given GraphQL query and deserializes the named field of the response.","sourceCodeStart":2216,"sourceCodeEnd":2252,"githubUrl":"https://github.com/linera-io/linera-protocol/blob/6c226ddcb332ef55118dc8d0aafbd093d5420899/linera-service/src/cli_wrappers/wallet.rs#L2216-L2252","documentation":"Raised by `NodeExt::query_node` in the linera-service test wrappers when a plain GraphQL query POSTed to the node's HTTP endpoint returns a 200 response whose body contains an `errors` array. The node's GraphQL layer rejected the query itself (syntax, validation, or execution error). The message includes the truncated query and the server's error list, so the exact cause is embedded in the error text.","triggerScenarios":"Calling `query_node` with a malformed GraphQL string (unbalanced braces, bad quoting from `format!`), unknown fields or arguments, wrong argument types, or IDs (chainId/applicationId/blockHash) that do not exist on that node.","commonSituations":"Hand-built query strings where interpolated IDs break string quoting; schema changes between the client wrapper and the node binary (fields renamed/removed); querying a chain or application that was never created on this node; tests running against a stale node fixture.","solutions":["Read the embedded `errors` array in the message — it names the exact GraphQL validation failure","Paste the printed query into the node's GraphQL playground (http://localhost:{port}) and fix the reported field/argument issues","Check quoting of `format!`-interpolated IDs (raw strings `r#\"...\"#` plus escaped quotes)","Align client and node versions — rebuild both from the same commit"],"exampleFix":"// before\nlet query = format!(\"query {{ block(chainId: \\\"{}\\\") {{ hash }} }}\", chain_id);\n\n// after\nlet query = format!(r#\"query {{ block(chainId: \"{chain_id}\") {{ hash }} }}\"#);","handlingStrategy":"try-catch","validationCode":"// Rust: smoke-test a dynamically built query against the schema before query_node\n// (cheap: run it once; if the schema rejects it, you get the error synchronously)\n#[cfg(test)]\nfn assert_query_is_single_operation(query: &str) -> anyhow::Result<()> {\n    let trimmed = query.trim();\n    anyhow::ensure!(\n        trimmed.starts_with(\"query\") || trimmed.starts_with(\"subscription\") || trimmed.starts_with('{'),\n        \"query does not look like a GraphQL operation: {trimmed}\"\n    );\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":"match node.query_node(&query).await {\n    Ok(value) => { /* use value */ }\n    Err(e) if e.to_string().contains(\"Query \\\"\") => {\n        // GraphQL-level failure: the message contains the truncated query + server errors.\n        // Log and surface it; retrying unchanged will fail again.\n        return Err(e);\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Build queries with raw-string format! (r#\"...\"#) so interpolated IDs keep their quotes intact","Test new queries once in the node's GraphQL playground before embedding them in tests","Read the embedded errors array in the message — it pinpoints the failing field or argument","Regenerate fixtures after SDK upgrades that rename GraphQL fields"],"tags":["graphql","http","query","linera-node","testing"],"backgroundTag":"graphql-query-errors","analyzedSha":"6c226ddcb332ef55118dc8d0aafbd093d5420899","analyzedAt":"2026-08-22T22:49:09.787Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}