{"record":{"id":"760a7022654eacba","repo":"hasura/graphql-engine","slug":"invalid-unicode-escape-sequence-in-string-0","errorCode":null,"errorMessage":"invalid unicode escape sequence in string. {0:?}","messagePattern":"invalid unicode escape sequence in string\\. (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/lexer/string.rs","lineNumber":36,"sourceCode":"    /// An unknown character in a string literal was found\n    ///\n    /// This occurs when an invalid source character is found in a string\n    /// literal, such as ASCII control characters.\n    #[error(\"unexpected character in string: {0:?}\")]\n    UnknownCharacterInString(char),\n\n    /// An unknown escape sequence in a string literal was found\n    ///\n    /// Only a limited set of escape sequences are supported, this is emitted\n    /// when e.g. `\"\\l\"` is parsed.\n    #[error(\"unknown escape sequence in string: {0:?}\")]\n    UnknownEscapeSequence(String),\n\n    /// An invalid unicode escape sequence in a string literal was found, and\n    /// an error message is provided.\n    ///\n    /// This began with `\"\\u\"` being parsed and then something going wrong.\n    #[error(\"invalid unicode escape sequence in string. {0:?}\")]\n    InvalidUnicodeEscapeSequence(String),\n}\n\npub struct Consumed {\n    /// Number of line breaks consumed.\n    pub line_breaks: usize,\n    /// Number of characters consumed without hitting a further line break.\n    pub chars_without_further_line_break: usize,\n}\n\nimpl Consumed {\n    fn no_line_break(chars: usize) -> Consumed {\n        Consumed {\n            line_breaks: 0,\n            chars_without_further_line_break: chars,\n        }\n    }\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/lexer/string.rs#L18-L54","documentation":"Thrown when a \\u escape in a GraphQL string is malformed: fewer than 4 hex digits follow \\u, or the digits do not form a valid scalar value. The detailed reason is embedded in the message.","triggerScenarios":"Parsing a string containing \"\\\\u12\" (truncated), \"\\\\uZZZZ\" (non-hex characters), or a surrogate code point that is invalid as a standalone scalar.","commonSituations":"Dynamically generating \\u escapes with string formatting that drops digits, truncation of pasted queries, or emitting unpaired surrogates from JSON-to-GraphQL converters.","solutions":["Ensure exactly 4 hexadecimal digits follow \\u","Re-check generated escapes for truncation or non-hex characters","Emit supplementary characters as a proper surrogate pair or use the literal character"],"exampleFix":"# before\n{ greet(name: \"\\\\u12\") }\n# after\n{ greet(name: \"\\\\u0012\") }","handlingStrategy":"validation","validationCode":"fn valid_unicode_escape(hex: &str) -> bool {\n    hex.len() == 4 && hex.chars().all(|c| c.is_ascii_hexdigit())\n        && u32::from_str_radix(hex, 16).map(|c| char::from_u32(c).is_some()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"Match on InvalidString(InvalidUnicodeEscapeSequence(msg)) and report the inner message with the string's position.","preventionTips":["Always emit exactly 4 hex digits after \\\\u","Prefer literal UTF-8 characters over \\\\u escapes when possible"],"tags":["graphql","lexer","unicode","escape-sequence"],"backgroundTag":"graphql-syntax-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}