{"record":{"id":"546abc5c170ef710","repo":"databendlabs/databend","slug":"expected-to-have-terminated-string-literal-after-q","errorCode":null,"errorMessage":"Expected to have terminated string literal after quota {:?}, while consumed buf: {:?}","messagePattern":"Expected to have terminated string literal after quota (.+?), while consumed buf: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/common/io/src/cursor_ext/cursor_read_string_ext.rs","lineNumber":79,"sourceCode":"                match c {\n                    b'n' => buf.push(b'\\n'),\n                    b't' => buf.push(b'\\t'),\n                    b'r' => buf.push(b'\\r'),\n                    b'0' => buf.push(b'\\0'),\n                    b'\\'' => buf.push(b'\\''),\n                    b'\\\"' => buf.push(b'\\\"'),\n                    b'\\\\' => buf.push(b'\\\\'),\n                    b'/' => buf.push(b'/'),\n                    _ => {\n                        buf.push(b'\\\\');\n                        buf.push(c);\n                    }\n                }\n            } else {\n                break;\n            }\n        }\n        Err(std::io::Error::new(\n            ErrorKind::InvalidData,\n            format!(\n                \"Expected to have terminated string literal after quota {:?}, while consumed buf: {:?}\",\n                quote as char, buf\n            ),\n        ))\n    }\n\n    fn read_escaped_string_text(&mut self, buf: &mut Vec<u8>) -> Result<()> {\n        loop {\n            self.keep_read(buf, |f| f != b'\\\\');\n            if self.ignore_byte(b'\\\\') {\n                let buffer = Cursor::split(self).1;\n                let c = buffer[0];\n                match c {\n                    b'\\'' | b'\\\"' | b'\\\\' | b'/' | b'`' => {\n                        buf.push(c);\n                        self.consume(1);","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/common/io/src/cursor_ext/cursor_read_string_ext.rs#L61-L97","documentation":"Thrown by `CursorReadStringExt::read_quoted_text` when the closing quote for a string literal is never found. The parser consumes bytes into `buf` until EOF (or a non-continuation branch breaks the loop) and then reports the expected quote character plus everything it consumed, so the developer can see how far parsing got.","triggerScenarios":"Calling `read_quoted_text` with a quote character (e.g. `'`) on input that opens the quote but never closes it: the entire remaining buffer is consumed and the error names the quote char and consumed buffer.","commonSituations":"Malformed SQL/text literals pasted from editors that stripped the closing quote, multi-line strings split across lines, or serialization bugs that emit one quote instead of two.","solutions":["Check the consumed buffer in the message — the missing closing quote is at the end of that content.","Ensure the literal is wrapped in a matching pair of the same quote character.","Fix the upstream producer/serializer so it always emits balanced quotes.","Validate literal balance with a quick count of unescaped quote chars before parsing."],"exampleFix":"// before\nlet input = \"'unterminated value\";\n// after\nlet input = \"'unterminated value'\";","handlingStrategy":"validation","validationCode":"fn balanced_quotes(input: &str, quote: char) -> bool {\n    let mut escaped = false;\n    let mut count = 0;\n    for c in input.chars() {\n        if escaped { escaped = false; continue; }\n        match c { '\\\\' => escaped = true, _ if c == quote => count += 1, _ => {} }\n    }\n    count % 2 == 0\n}","typeGuard":"fn is_closed_literal(s: &str) -> bool {\n    let b = s.as_bytes();\n    b.len() >= 2 && b[b.len()-1] == b[0] && (b[0] == b'\\'' || b[0] == b'\"')\n}","tryCatchPattern":"match read_quoted_text(&mut buf) {\n    Ok(s) => s,\n    Err(e) => {\n        // message includes the consumed buffer; surface it for diagnostics\n        return Err(anyhow!(\"unterminated literal: {e}\"));\n    }\n}","preventionTips":["Validate quote balance before parsing user-supplied literals.","Escape quote characters inside literal content.","Fix upstream serializers to always close quoted values."],"tags":["parsing","string-literal","unterminated"],"backgroundTag":"unterminated-string-literal","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}