rustfs/rustfs · error · io::Error

chunk read limit must be non-zero

Error message

chunk read limit must be non-zero

What it means

Programming-guard error: poll_read_chunk was invoked with a max chunk size of zero, which is not a meaningful read request. Indicates a caller bug in the chunked HTTP reader, not a data or network problem.

Source

Thrown at crates/rio/src/http_reader.rs:1219

        if buf.remaining() == 0 {
            return Poll::Ready(Ok(()));
        }
        match ChunkReader::poll_read_chunk(self.as_mut(), cx, buf.remaining()) {
            Poll::Ready(Ok(Some(chunk))) => {
                buf.put_slice(&chunk);
                Poll::Ready(Ok(()))
            }
            Poll::Ready(Ok(None)) => Poll::Ready(Ok(())),
            Poll::Ready(Err(err)) => Poll::Ready(Err(err)),
            Poll::Pending => Poll::Pending,
        }
    }
}

impl ChunkReader for HttpChunkReader {
    fn poll_read_chunk(self: Pin<&mut Self>, cx: &mut Context<'_>, max: usize) -> Poll<io::Result<Option<Bytes>>> {
        if max == 0 {
            return Poll::Ready(Err(Error::new(io::ErrorKind::InvalidInput, "chunk read limit must be non-zero")));
        }

        let mut this = self.project();
        if *this.consecutive_empty_chunks >= MAX_CONSECUTIVE_EMPTY_CHUNKS {
            return Poll::Ready(Err(excessive_empty_chunks_error()));
        }
        loop {
            if let Some(mut current) = this.current.take() {
                let take = current.len().min(max);
                let chunk = current.split_to(take);
                if !current.is_empty() {
                    *this.current = Some(current);
                }
                record_internode_recv_bytes(*this.track_internode_metrics, *this.internode_operation, take);
                *this.stall_timer = None;
                return Poll::Ready(Ok(Some(chunk)));
            }

View on GitHub (pinned to 35af688cd9)

Solutions

  1. Pass a non-zero max when polling for chunks
  2. Guard call sites that compute max from possibly-zero sizes
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/rio/src/http_reader.rs:1219 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of rustfs/rustfs@35af688cd9 (2026-08-20). Data as JSON: /api/errors/1db7de2190f910e1. Report an issue: GitHub.