{"record":{"id":"6cb43ea02267aa83","repo":"hasura/graphql-engine","slug":"invalid-string-literal-found-0","errorCode":null,"errorMessage":"invalid string literal found: {0:?}","messagePattern":"invalid string literal found: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/lexer.rs","lineNumber":151,"sourceCode":"/// 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\n    #[error(\"invalid graphql name: {0}\")]\n    InvalidGraphQlName(String),\n}\n\nimpl From<ast::common::InvalidGraphQlName> for Error {\n    fn from(error: ast::common::InvalidGraphQlName) -> Self {\n        Error::InvalidGraphQlName(error.0)\n    }\n}\n\npub type Result = core::result::Result<Spanning<Token>, Positioned<Error>>;","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/lexer.rs#L133-L169","documentation":"Wrapper error: the lexer's string sub-scanner (string::Error — unterminated string, invalid character, bad escape, bad unicode escape) failed while scanning a string literal, and the detail is included via {0:?}.","triggerScenarios":"Any string-literal scanning failure: unterminated quote, raw control character (UnknownCharacterInString), unknown escape (UnknownEscapeSequence), or malformed \\u (InvalidUnicodeEscapeSequence).","commonSituations":"Umbrella error seen at the parser level when any of the string scanning rules are violated, typically from unescaped user-supplied text interpolated into queries.","solutions":["Look at the inner string::Error variant for the specific cause","Apply the corresponding fix (escape, terminate the string, fix \\u)","Consider using variables instead of inlining user text into string literals"],"exampleFix":"// before\nformat!(\"{{ search(term: \\\"{}\\\") }}\", user_input)  // breaks if input has quotes/backslashes\n// after\nuse variables: query($term: String!) { search(term: $term) } with parameter binding","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"fn is_string_lex_error(e: &lexer::Error) -> bool { matches!(e, lexer::Error::InvalidString(_)) }","tryCatchPattern":"match result { Err(lexer::Error::InvalidString(inner)) => match inner { string::Error::Unterminated => ..., string::Error::UnknownEscapeSequence(seq) => ..., _ => ... }, _ => {} }","preventionTips":["Interpolate values via GraphQL variables, not string literals","Escape user text with a GraphQL-string escaper"],"tags":["graphql","lexer","string-literal","wrapper"],"backgroundTag":"graphql-syntax-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}