{"record":{"id":"d9e73f9b700bfe37","repo":"databendlabs/databend","slug":"expected-to-have-insensitive-bytes","errorCode":null,"errorMessage":"Expected to have insensitive bytes {:?}","messagePattern":"Expected to have insensitive bytes (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs","lineNumber":59,"sourceCode":"        }\n        Ok(())\n    }\n\n    fn must_ignore_byte(&mut self, b: u8) -> Result<()>;\n\n    fn must_ignore_bytes(&mut self, bs: &[u8]) -> Result<()> {\n        if !self.ignore_bytes(bs) {\n            return Err(std::io::Error::new(\n                ErrorKind::InvalidData,\n                format!(\"Expected to have bytes {:?}\", bs),\n            ));\n        }\n        Ok(())\n    }\n\n    fn must_ignore_insensitive_bytes(&mut self, bs: &[u8]) -> Result<()> {\n        if !self.ignore_insensitive_bytes(bs) {\n            return Err(std::io::Error::new(\n                ErrorKind::InvalidData,\n                format!(\"Expected to have insensitive bytes {:?}\", bs),\n            ));\n        }\n        Ok(())\n    }\n}\n\nimpl<T> ReadBytesExt for Cursor<T>\nwhere T: AsRef<[u8]>\n{\n    fn peek(&self) -> Option<char> {\n        let buf = Cursor::split(self).1;\n        if buf.is_empty() {\n            None\n        } else {\n            Some(buf[0] as char)\n        }","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs#L41-L77","documentation":"CursorReadBytesExt::must_ignore_insensitive_bytes consumes the expected bytes case-insensitively (ASCII). If the upcoming bytes are not a case-insensitive match for bs, or the cursor runs out, it raises an InvalidData io error embedding the expected sequence.","triggerScenarios":"Calling must_ignore_insensitive_bytes(bs) when the next bytes differ from bs even ignoring case, or EOF is reached mid-sequence.","commonSituations":"Parsing case-insensitive keywords or header markers (e.g. SQL tokens, HTTP-style headers) from malformed input or with wrong expectations about capitalization/whitespace.","solutions":["Dump the bytes at the cursor and compare with the expected sequence, accounting for case-insensitivity.","Use ignore_insensitive_bytes(bs) if the token is optional.","Confirm the input's actual keyword spelling/format matches what the parser expects."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if !cursor.ignore_insensitive_bytes(b\"SELECT\") {\n    return Err(anyhow!(\"expected keyword SELECT\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Consume leading whitespace before matching keywords.","Use ignore_insensitive_bytes for optional case-insensitive tokens.","Test parsers against inputs with unexpected casing and trailing data."],"tags":["parsing","io","rust","cursor"],"backgroundTag":"invalid-argument-format","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}