You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "bavardage (via GitHub)" <gi...@apache.org> on 2026/08/26 15:51:13 UTC

[PR] fix(core): Return Ok(0) instead of panicking on zero-length write [opendal]

bavardage opened a new pull request, #8162:
URL: https://github.com/apache/opendal/pull/8162

   `FuturesAsyncWriter::poll_write` panicked with `frozen buffer must be valid` when called with an empty buffer, even though both `std::io::Write::write` and `futures::AsyncWrite::poll_write` allow a zero-length input and specify `Ok(0)` as the result.
   
   `FlexBuf::put` returns 0 both when the buffer is already frozen and when the input slice is empty. The loop in `poll_write` assumed only the first case, so on an empty input it called `get()` on a buffer that was never frozen and hit the `expect`. `BufferSink` already guards this case, so add the same guard to the adapter.
   
   The blocking `StdWriter` path is fixed transitively, since it forwards to `FuturesAsyncWriter::write`.
   
   Closes #8161
   
   # Which issue does this PR close?
   
   Closes #8161
   
   # What changes are included in this PR?
   
   - `core/core/src/types/write/futures_async_writer.rs`: return `Poll::Ready(Ok(0))` from
   `poll_write` when the input buffer is empty, before entering the drain loop.
   - A unit test in the same file’s existing mod tests, covering an empty write before and
   after a non-empty one, and asserting the surrounding payload still commits and reads back
   intact.
   
   
   # Are there any user-facing changes?
   
   Yes but nothing breaking. The zero length previously panicked and now returns `Ok(0)`. No API signature
   changes, and no behavior change for any non-empty write.
   
   
   # AI Usage Statement
   AI identified this bug when using opendal in my project and identified this as a potential fix.
   The fix is pretty simple though!
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] fix(core): Return Ok(0) instead of panicking on zero-length write [opendal]

Posted by "Xuanwo (via GitHub)" <gi...@apache.org>.
Xuanwo merged PR #8162:
URL: https://github.com/apache/opendal/pull/8162


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org