{"record":{"id":"886faff44f8fe057","repo":"hasura/graphql-engine","slug":"0-886faf","errorCode":null,"errorMessage":"{0}","messagePattern":"\\{0\\}","errorType":"validation","errorClass":"GraphQlParseError","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/frontend/src/types.rs","lineNumber":84,"sourceCode":"        }\n    }\n\n    pub fn inner(self) -> gql::http::Response {\n        self.0\n    }\n}\n\n/// Implement traceable for GraphQL Response\nimpl Traceable for GraphQLResponse {\n    type ErrorType<'a> = GraphQLErrors<'a>;\n\n    fn get_error(&self) -> Option<GraphQLErrors<'_>> {\n        self.0.errors.as_ref().map(GraphQLErrors)\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\n#[error(\"{0}\")]\npub struct GraphQlParseError(#[from] pub gql::ast::spanning::Positioned<gql::parser::Error>);\n\nimpl TraceableError for GraphQlParseError {\n    fn visibility(&self) -> ErrorVisibility {\n        ErrorVisibility::User\n    }\n}\n\n#[derive(Debug, thiserror::Error)]\n#[error(\"{0}\")]\npub struct GraphQlValidationError(#[from] pub gql::validation::Error);\nimpl TraceableError for GraphQlValidationError {\n    fn visibility(&self) -> ErrorVisibility {\n        ErrorVisibility::User\n    }\n}\n","sourceCodeStart":66,"sourceCodeEnd":101,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/frontend/src/types.rs#L66-L101","documentation":"GraphQlParseError is a thin newtype over the gql parser error (with source position) raised when parsing a GraphQL document fails in contexts where a standalone TraceableError is required. Its Display is transparent ('{0}'), so the message shown is the parser's own diagnostic. It is marked User-visible, meaning it is safe to return to API clients.","triggerScenarios":"Any code path that constructs GraphQlParseError — typically parsing stored/incoming GraphQL documents (e.g. persisted queries, schema documents, websocket message payloads) where the text is not valid GraphQL syntax.","commonSituations":"Corrupted or truncated persisted query strings; user-supplied GraphQL text stored in a database later re-parsed; whitespace/encoding issues (BOM, CRLF) in query files; queries written against a different GraphQL dialect.","solutions":["Inspect the wrapped gql::parser::Error position to find the offending token and fix the document","Sanitize/validate GraphQL text at ingestion time rather than when re-parsing later","Add round-trip tests (parse → print → parse) for generated or stored documents","Check for encoding issues (UTF-8 BOM, non-breaking spaces) if the text looks valid"],"exampleFix":"// before\nlet doc = gql::parser::parse_schema(&raw)?;\n\n// after\nmatch graphql_frontend::types::GraphQlParseError::from_parser(&raw) {\n    Ok(doc) => doc,\n    Err(e) => { return Err(bad_request(format!(\"invalid GraphQL: {e}\"))); }\n}","handlingStrategy":"validation","validationCode":"// Validate stored documents at write time, not read time:\nfn store_query(raw: &str) -> Result<(), String> {\n    gql_parse_check(raw).map_err(|e| format!(\"invalid GraphQL: {e} at {}\", e.pos))?;\n    db.insert(raw);\n    Ok(())\n}","typeGuard":"fn is_parse_error(e: &dyn std::error::Error) -> bool {\n    e.downcast_ref::<graphql_frontend::types::GraphQlParseError>().is_some()\n}","tryCatchPattern":"use graphql_frontend::types::GraphQlParseError;\nmatch parse_document(raw) {\n    Ok(doc) => doc,\n    Err(e) => {\n        let e = GraphQlParseError::from(e); // TraceableError, User-visible\n        return Err(UserVisible(e.to_string()));\n    }\n}","preventionTips":["Never store unvalidated GraphQL text; parse before persisting","Fuzz/round-trip test any query generation code","Strip BOM and normalize encoding before parsing external text"],"tags":["rust","graphql","parsing","syntax-error","newtype"],"backgroundTag":"graphql-parse-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}