{"record":{"id":"7ce0c7544e5a5b99","repo":"hasura/graphql-engine","slug":"unexpected-character-in-the-document-0","errorCode":null,"errorMessage":"unexpected character in the document: {0:?}","messagePattern":"unexpected character in the document: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/lexer.rs","lineNumber":140,"sourceCode":"    }\n}\n\n#[derive(Debug)]\npub struct Lexer<'a> {\n    bytes: &'a [u8],\n    ix: usize,\n    line: usize,\n    column: usize,\n}\n\n/// Error when tokenizing the input source\n#[derive(Error, Debug, PartialEq, Eq, Clone)]\npub enum Error {\n    /// An unexpected character was found\n    ///\n    /// Unexpected characters are characters that _do_ exist in the GraphQL\n    /// language, but is not expected at the current position in the document.\n    #[error(\"unexpected character in the document: {0:?}\")]\n    UnexpectedCharacter(char),\n\n    /// The input source was unexpectedly terminated\n    ///\n    /// Emitted when the current token requires a succeeding character, but\n    /// the source has reached EOF. Emitted when scanning e.g. `\"1.\"`.\n    #[error(\"end of file reached when expecting further input\")]\n    UnexpectedEndOfFile,\n\n    /// An invalid string literal was found\n    #[error(\"invalid string literal found: {0:?}\")]\n    InvalidString(string::Error),\n\n    /// An invalid number literal was found\n    #[error(\"invalid number literal found: {0:?}\")]\n    InvalidNumber(number::Error),\n\n    // An invalid graphql name","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/lexer.rs#L122-L158","documentation":"General lexer error for a character that exists in the GraphQL language but is not valid at the current position while scanning a token, e.g. a stray punctuation mark where a name, number, or string should begin.","triggerScenarios":"Scanning a document where a token starts with or contains unexpected punctuation: '@' in the middle of a name, '#' inside a token (comments must start a token), '}' or ')' where a value is expected mid-lex, etc.","commonSituations":"Hand-edited queries with misplaced brackets, template placeholders left unfilled, or concatenating fragments incorrectly so punctuation lands mid-token.","solutions":["Check the reported position for a misplaced or extra punctuation character","Verify template interpolation produced valid GraphQL","Re-format/validate the query in a GraphQL editor or linter"],"exampleFix":"# before\n{ user(id: @1) { name } }   # @ is not valid here\n# after\n{ user(id: 1) { name } }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"let tokens: Result<Vec<_>, _> = lexer::Lexer::new(src).collect(); match tokens { Err(e @ Error::UnexpectedCharacter(c)) => report_position(e), _ => {} }","preventionTips":["Validate queries with a GraphQL linter/IDE before sending","Use parameterized queries instead of string concatenation"],"tags":["graphql","lexer","syntax","parsing"],"backgroundTag":"graphql-syntax-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}