Skip to content

object-store: status code from client errors are not always accessible #5345

@thinkharderdev

Description

@thinkharderdev

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

When we get a client error (HTTP status code 4xx), the status code is not always accessible from client code.

                                return Err(match status.is_client_error() {
                                    true => match r.text().await {
                                        Ok(body) => {
                                            Error::Client {
                                                body: Some(body).filter(|b| !b.is_empty()),
                                                status,
                                            }
                                        }
                                        Err(e) => {
                                            Error::Reqwest {
                                                retries,
                                                max_retries,
                                                elapsed: now.elapsed(),
                                                retry_timeout,
                                                source: e,
                                            }
                                        }
                                    }
                                    false => Error::Reqwest {
                                        retries,
                                        max_retries,
                                        elapsed: now.elapsed(),
                                        retry_timeout,
                                        source: e,
                                    }
                                });

if there is a response body, we ultimately return a generic error with source of type object_store::client::retry::Error::Client

Since object_store::client::retry::Error is crate private you cannot downcast the source to this in client code and hence cannot access the status code

Describe the solution you'd like

The status code should be accessible since it can be important to error handling logic in application code

Describe alternatives you've considered

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAny new improvement worthy of a entry in the changelog

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions