public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox 3/3] s3 client: log error response body for invalid request status codes
Date: Wed, 23 Jul 2025 12:26:01 +0200	[thread overview]
Message-ID: <20250723102601.495806-4-c.ebner@proxmox.com> (raw)
In-Reply-To: <20250723102601.495806-1-c.ebner@proxmox.com>

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@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



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  parent reply	other threads:[~2025-07-23 10:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 10:25 [pbs-devel] [PATCH proxmox 0/3] s3 client: improve error logging for invalid requests Christian Ebner
2025-07-23 10:25 ` [pbs-devel] [PATCH proxmox 1/3] s3 client: fix minor whitespace issue Christian Ebner
2025-07-23 10:26 ` [pbs-devel] [PATCH proxmox 2/3] s3 client: refactor error response body into dedicated helper Christian Ebner
2025-07-23 10:26 ` Christian Ebner [this message]
2025-07-23 11:31 ` [pbs-devel] [PATCH proxmox 0/3] s3 client: improve error logging for invalid requests Lukas Wagner
2025-07-23 11:51 ` [pbs-devel] applied: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250723102601.495806-4-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal