databendlabs/databend · error
Expected to have insensitive bytes
Error message
Expected to have insensitive bytes {:?} What it means
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.
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.
Defensive patterns
Strategy: validation
Validate before calling
if !cursor.ignore_insensitive_bytes(b"SELECT") {
return Err(anyhow!("expected keyword SELECT"));
} Prevention
- 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.
When it happens
Trigger: Calling must_ignore_insensitive_bytes(bs) when the next bytes differ from bs even ignoring case, or EOF is reached mid-sequence.
Common situations: Parsing case-insensitive keywords or header markers (e.g. SQL tokens, HTTP-style headers) from malformed input or with wrong expectations about capitalization/whitespace.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- Expected to ignore a byte
- Expected to have bytes
- Must reach the buffer end
- Invalid temp table desc
- Expected to have char
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/d9e73f9b700bfe37.
Report an issue: GitHub.
Appendix: source
Thrown at src/common/io/src/cursor_ext/cursor_read_bytes_ext.rs:59
}
Ok(())
}
fn must_ignore_byte(&mut self, b: u8) -> Result<()>;
fn must_ignore_bytes(&mut self, bs: &[u8]) -> Result<()> {
if !self.ignore_bytes(bs) {
return Err(std::io::Error::new(
ErrorKind::InvalidData,
format!("Expected to have bytes {:?}", bs),
));
}
Ok(())
}
fn must_ignore_insensitive_bytes(&mut self, bs: &[u8]) -> Result<()> {
if !self.ignore_insensitive_bytes(bs) {
return Err(std::io::Error::new(
ErrorKind::InvalidData,
format!("Expected to have insensitive bytes {:?}", bs),
));
}
Ok(())
}
}
impl<T> ReadBytesExt for Cursor<T>
where T: AsRef<[u8]>
{
fn peek(&self) -> Option<char> {
let buf = Cursor::split(self).1;
if buf.is_empty() {
None
} else {
Some(buf[0] as char)
}View on GitHub (pinned to 288d84d76e)