Skip to content

Commit

Permalink
fix: return an error for non-2xx responses using error_for_status()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
coreyphillips committed Dec 11, 2024
1 parent 857ab88 commit bfc1850
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pubky/src/shared/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down

0 comments on commit bfc1850

Please sign in to comment.