{"record":{"id":"f242e13a04f44094","repo":"hasura/graphql-engine","slug":"string-is-unterminated","errorCode":null,"errorMessage":"string is unterminated","messagePattern":"string is unterminated","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"v3/crates/graphql/lang-graphql/src/lexer/string.rs","lineNumber":15,"sourceCode":"use std::cmp::min;\nuse std::str::from_utf8_unchecked;\nuse thiserror::Error;\n\n#[derive(Error, Debug, PartialEq, Eq, Clone)]\npub enum Error {\n    #[error(\"expected a \\\" but found: {0:?}\")]\n    StartingSequenceNotFound(Option<u8>),\n\n    /// An unterminated string literal was found\n    ///\n    /// Apart from forgetting the ending `\"`, terminating a string within a\n    /// Unicode escape sequence or having a line break in the string also\n    /// causes this error.\n    #[error(\"string is unterminated\")]\n    Unterminated,\n\n    /// 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.","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/hasura/graphql-engine/blob/724551b9ae87845594ef0408cff0e50eb6c90dc5/v3/crates/graphql/lang-graphql/src/lexer/string.rs#L1-L33","documentation":"String lexer error: a string literal was never terminated. Beyond a missing closing quote, ending a string inside a Unicode escape sequence or including a raw line break also triggers it, since GraphQL strings cannot span lines.","triggerScenarios":"Forgetting the closing '\"'; a literal newline pasted inside a quoted string; a truncated query that ends mid-string; an unterminated \\u escape.","commonSituations":"Multiline text pasted into an inline string argument; client template bugs; network truncation mid-request.","solutions":["Close the string literal, escaping any embedded quotes or newlines","Pass multiline text as a variable instead of an inline literal","Verify the request body is fully transmitted (not truncated)"],"exampleFix":"# before\nquery { songs(where: {title: {_eq: \"hey}}) }\n# after\nquery($t: String!) { songs(where: {title: {_eq: $t}}) }","handlingStrategy":"validation","validationCode":"// Client-side parse catches unterminated strings before sending\nimport { parse } from 'graphql';\ntry { parse(queryText); } catch (e) { fixQuery(e); }","typeGuard":"const isTerminatedString = (s) => (s.match(/\"/g) ?? []).length % 2 === 0;","tryCatchPattern":"// Catch the lexer error, use its offset to locate the string, close or escape it","preventionTips":["Escape embedded quotes/newlines or use variables","Verify request bodies aren't truncated by proxies"],"tags":["graphql","lexer","string","unterminated","parse-error"],"backgroundTag":"graphql-string-lex-error","analyzedSha":"724551b9ae87845594ef0408cff0e50eb6c90dc5","analyzedAt":"2026-08-28T07:32:55.105Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}