{"record":{"id":"e544d866dd909c1a","repo":"hasura/graphql-engine","slug":"parsing-failed-0","errorCode":null,"errorMessage":"parsing failed: {0}","messagePattern":"parsing failed: (.+?)","errorType":"validation","errorClass":"RequestError::ParseFailure","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/frontend/src/error.rs","lineNumber":11,"sourceCode":"use axum::response::IntoResponse;\nuse engine_types::ExposeInternalErrors;\nuse gql::http::GraphQLError;\nuse lang_graphql as gql;\nuse tracing_util::{ErrorVisibility, TraceableError};\n\n/// Request errors are raised before execution of root fields begins.\n/// Ref: <https://spec.graphql.org/October2021/#sec-Errors.Request-errors>\n#[derive(Debug, thiserror::Error)]\npub enum RequestError {\n    #[error(\"parsing failed: {0}\")]\n    ParseFailure(#[from] gql::ast::spanning::Positioned<gql::parser::Error>),\n\n    #[error(\"validation failed: {0}\")]\n    ValidationFailed(#[from] gql::validation::Error),\n\n    #[error(\"{0}\")]\n    IRConversionError(#[from] graphql_ir::Error),\n\n    #[error(\"{0}\")]\n    GraphQlPlanError(#[from] graphql_ir::GraphqlIrPlanError),\n\n    #[error(\"explain error: {0}\")]\n    ExplainError(String),\n}\n\nimpl RequestError {\n    pub fn to_graphql_error(&self, expose_internal_errors: ExposeInternalErrors) -> GraphQLError {\n        let message = match (self, expose_internal_errors) {","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/frontend/src/error.rs#L1-L29","documentation":"RequestError::ParseFailure is raised by the GraphQL frontend when the incoming GraphQL query string cannot be parsed into an AST. It transparently wraps the underlying gql parser error (including its source position), so the message is 'parsing failed: {0}' with the parser's own diagnostic appended. This is a request error per the GraphQL spec: it occurs before any root field execution begins.","triggerScenarios":"Sending a malformed GraphQL document to the GraphQL API: unbalanced braces/brackets, missing selection set, invalid tokens, bad syntax in argument literals, or a stray keyword. Produced during request parsing in graphql/frontend before validation or IR conversion.","commonSituations":"Typos in hand-written queries; clients concatenating query fragments incorrectly; sending a JSON-encoded query with escaped characters mangled; automated tooling generating invalid GraphQL; sending a mutation keyword where the parser expects a query.","solutions":["Fix the GraphQL syntax error indicated by the wrapped parser error and its position","Paste the query into a GraphQL IDE/linter (GraphiQL, graphql-inspector) to locate the syntax problem","If generating queries programmatically, validate generated strings against the schema in tests","Ensure the query field in the JSON request body is the raw GraphQL document, not double-encoded"],"exampleFix":"// before\nquery { user(id: 1 { name }\n\n// after\nquery { user(id: 1) { name } }","handlingStrategy":"validation","validationCode":"// Validate document syntax before sending to the server:\n// (js) use graphql-js `parse` client-side\nimport { parse } from 'graphql';\nfunction safeQuery(q) {\n  try { parse(q); return q; } catch (e) { throw new Error(`Invalid GraphQL syntax: ${e.message}`); }\n}","typeGuard":null,"tryCatchPattern":"match graphql_frontend::execute_request(&req).await {\n    Err(e) if matches!(e, RequestError::ParseFailure(_)) => {\n        // 400 Bad Request with the parser diagnostic (includes position)\n        bad_request(e.to_string())\n    }\n    rest => rest,\n}","preventionTips":["Lint queries in CI with graphql-inspector or similar before deploy","Use typed codegen clients so hand-written syntax errors never reach production","Return 400 (not 500) for parse failures since they are client errors"],"tags":["rust","graphql","parsing","syntax-error","request-error"],"backgroundTag":"graphql-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}