Skip to content

bug: incorrect Display implementation for BytesRange #8386

Closed

Description

@zqianem

OpenDAL version or commit

v0.59.3

Affected service or component

opendal-core

Describe the bug

In the Display::fmt implementation for ByteRange, some match arms return an error, which is not allowed and causes the panic below.

Steps to Reproduce

use opendal::BytesRange;

println!("{}", BytesRange::Range { offset:0, size: Some(0) }");

Actual Behavior

thread 'main' (84429) panicked at /rustc/59807616e1fa2540724bfbac14d7976d7e4a3860/library/std/src/io/mod.rs:648:17:
a formatting trait implementation returned an error when the underlying stream did not

Expected Behavior

no panic

Additional Context

No response

Reproduction confirmation

  • I reproduced this issue against the affected component. For a service-specific report, I used the actual service rather than only a mock, emulator, or source-code analysis.

Are you willing to submit a PR to fix this bug?

  • Yes, I would like to submit a PR.

Activity

  1. akshat-lakhera commented on Oct 11, 2026

    @akshat-lakhera

    Hey @zqianem, I'd like to take this one and send a PR.

    Display for BytesRange returns an error for a zero-size range and on offset+size overflow, which makes format! panic. My plan is to render a valid string for those cases instead of returning Err, and add unit tests for both. I'll look at #8343 first so we don't overlap.

  2. zqianem commented on Oct 11, 2026

    @zqianem
    Author

    Sure, go for it (I wasn't planning on a PR; no need to ask me for permission).

    One thing to keep in mind is that it seems like that the Display implementation is being used to create the HTTP range requests, so perhaps this logic needs to be split between general Displaying and outputting a valid range request.

    (I don't really know anything about this codebase though, so defer to the maintainers if you have any questions.)

  3. akshat-lakhera commented on Oct 12, 2026

    @akshat-lakhera

    Thanks @zqianem, I would consider your point while implementing,
    Can you le me know tell are the maintainer of this org so I can ping then up.

  4. zqianem commented on Oct 12, 2026

    @zqianem
    Author

    Generally you shouldn't ping the maintainers of a repository — they will see this issue and/or your PR eventually.

    It doesn't seem like GitHub has a place to see all the maintainers but if they comment on an issue or PR, they will have a "Member" badge next to their name (like how I have an "Author" badge when I comment in this issue).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcore

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions