quickwit-oss/tantivy · error
buffer should be empty
Error message
buffer should be empty
What it means
Fires at the end of ManagedDirectory::open_write. A fresh BufWriter wrapping the underlying writer must have an empty internal buffer; after into_inner() flushes and returns the raw writer, a Some(buffer) means buffered bytes were still pending — i.e. the flush into the inner writer failed silently or the writer was misused. This generic guard catches that corruption path rather than letting a partially written file proceed.
Source
Thrown at src/directory/managed_directory.rs:293
}
fn open_read(&self, path: &Path) -> result::Result<FileSlice, OpenReadError> {
let file_slice = self.directory.open_read(path)?;
let (footer, reader) = Footer::extract_footer(file_slice)
.map_err(|io_error| OpenReadError::wrap_io_error(io_error, path.to_path_buf()))?;
footer.is_compatible()?;
Ok(reader)
}
fn open_write(&self, path: &Path) -> result::Result<WritePtr, OpenWriteError> {
self.register_file_as_managed(path)
.map_err(|io_error| OpenWriteError::wrap_io_error(io_error, path.to_path_buf()))?;
Ok(io::BufWriter::new(Box::new(FooterProxy::new(
self.directory
.open_write(path)?
.into_inner()
.map_err(|_| ())
.expect("buffer should be empty"),
))))
}
fn atomic_write(&self, path: &Path, data: &[u8]) -> io::Result<()> {
self.register_file_as_managed(path)?;
self.directory.atomic_write(path, data)
}
fn atomic_read(&self, path: &Path) -> result::Result<Vec<u8>, OpenReadError> {
self.directory.atomic_read(path)
}
fn delete(&self, path: &Path) -> result::Result<(), DeleteError> {
self.directory.delete(path)
}
fn exists(&self, path: &Path) -> Result<bool, OpenReadError> {
self.directory.exists(path)View on GitHub (pinned to b5d8deb80c)
Solutions
- Investigate why BufWriter::into_inner returned Err (typically an IO error during the final flush)
- Ensure the underlying writer (FooterProxy) does not error on flush for this path
- Surface the flush IO error to callers instead of discarding it with map_err(|_| ())
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at src/directory/managed_directory.rs:293 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of quickwit-oss/tantivy@b5d8deb80c (2026-09-05).
Data as JSON: /api/errors/f1dd7876aa6dba00.
Report an issue: GitHub.