From bfc18502ce35af33338083332e08a1af22481aa5 Mon Sep 17 00:00:00 2001 From: coreyphillips Date: Wed, 11 Dec 2024 15:50:28 -0500 Subject: [PATCH 1/2] fix: return an error for non-2xx responses using error_for_status() Previously, the request function returned Ok(()) even if the HTTP response status was an error (4xx/5xx). By adding `response.error_for_status()?`, we correctly propagate HTTP errors rather than masking them, ensuring that timeouts and other non-2xx status codes produce an error as expected. --- pubky/src/shared/auth.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pubky/src/shared/auth.rs b/pubky/src/shared/auth.rs index 0dff599..8754b5a 100644 --- a/pubky/src/shared/auth.rs +++ b/pubky/src/shared/auth.rs @@ -143,11 +143,13 @@ impl PubkyClient { path_segments.push(&channel_id); drop(path_segments); - self.request(Method::POST, callback) + let response = self.request(Method::POST, callback) .body(encrypted_token) .send() .await?; + response.error_for_status()?; + Ok(()) } From 980bee20410c59a6842ba2010691cad212b07fff Mon Sep 17 00:00:00 2001 From: coreyphillips Date: Wed, 11 Dec 2024 16:09:34 -0500 Subject: [PATCH 2/2] style: fix indentation in inner_send_auth_token --- pubky/src/shared/auth.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pubky/src/shared/auth.rs b/pubky/src/shared/auth.rs index 8754b5a..5c37f48 100644 --- a/pubky/src/shared/auth.rs +++ b/pubky/src/shared/auth.rs @@ -143,7 +143,8 @@ impl PubkyClient { path_segments.push(&channel_id); drop(path_segments); - let response = self.request(Method::POST, callback) + let response = self + .request(Method::POST, callback) .body(encrypted_token) .send() .await?;