[pbs-devel] [PATCH proxmox 3/3] s3 client: log error response body for invalid request status codes
Christian Ebner
c.ebner at proxmox.com
Wed Jul 23 12:26:01 CEST 2025
While the response body is already logged via `tracing` in case of
unexpected status codes, this is not the case for invalid request
response codes.
Log the error response body for these cases as well, as they might
contain further information to help debug issues. For example,
an incorrectly composed delete_objects call might return the
following error in the response body (reformatted from single line
to multi line for better readability in the commit message):
```
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>MalformedXML</Code>
<Message>The XML you provided was not well formed or did not validate against our published schema.</Message>
</Error>
```
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
proxmox-s3-client/src/response_reader.rs | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/proxmox-s3-client/src/response_reader.rs b/proxmox-s3-client/src/response_reader.rs
index 7aed4201..d8ca3b19 100644
--- a/proxmox-s3-client/src/response_reader.rs
+++ b/proxmox-s3-client/src/response_reader.rs
@@ -250,7 +250,10 @@ impl ResponseReader {
StatusCode::OK => (),
StatusCode::PRECONDITION_FAILED => return Ok(PutObjectResponse::PreconditionFailed),
StatusCode::CONFLICT => return Ok(PutObjectResponse::NeedsRetry),
- StatusCode::BAD_REQUEST => bail!("invalid request"),
+ StatusCode::BAD_REQUEST => {
+ Self::log_error_response_utf8(body);
+ bail!("invalid request");
+ }
status_code => {
Self::log_error_response_utf8(body);
bail!("unexpected status code {status_code}")
@@ -283,7 +286,10 @@ impl ResponseReader {
match parts.status {
StatusCode::OK => (),
- StatusCode::BAD_REQUEST => bail!("invalid request"),
+ StatusCode::BAD_REQUEST => {
+ Self::log_error_response_utf8(body);
+ bail!("invalid request");
+ }
status_code => {
Self::log_error_response_utf8(body);
bail!("unexpected status code {status_code}")
--
2.47.2
More information about the pbs-devel
mailing list