From a82ccf106912eb3a09bee96b99eb42ca1ef3f07b Mon Sep 17 00:00:00 2001 From: Johannes Marbach Date: Tue, 25 Nov 2025 16:25:08 +0100 Subject: [PATCH] fix(oauth): expose client API errors when receiving messages on rendezvous channel Signed-off-by: Johannes Marbach --- .../oauth/qrcode/rendezvous_channel.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs index 3271dcc05..547732ee0 100644 --- a/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs +++ b/crates/matrix-sdk/src/authentication/oauth/qrcode/rendezvous_channel.rs @@ -21,7 +21,7 @@ use http::{ use matrix_sdk_base::sleep; use ruma::api::{ EndpointError, - error::{FromHttpResponseError, HeaderDeserializationError, IntoHttpError, MatrixError}, + error::{FromHttpResponseError, HeaderDeserializationError, IntoHttpError}, }; use tracing::{debug, instrument, trace}; use url::Url; @@ -93,8 +93,8 @@ pub(super) struct RendezvousChannel { fn response_to_error(status: StatusCode, body: Vec) -> HttpError { match http::Response::builder().status(status).body(body).map_err(IntoHttpError::from) { Ok(response) => { - let error = FromHttpResponseError::::Server(RumaApiError::Other( - MatrixError::from_http_response(response), + let error = FromHttpResponseError::::Server(RumaApiError::ClientApi( + ruma::api::client::Error::from_http_response(response), )); error.into() @@ -257,13 +257,16 @@ impl RendezvousChannel { debug!("Received data from the rendezvous channel {response:?}"); let status_code = response.status(); - let headers = response.headers(); + if status_code.is_client_error() { + return Err(response_to_error(status_code, response.bytes().await?.to_vec())); + } + + let headers = response.headers(); let etag = get_header(headers, &ETAG)?; let expires = get_header(headers, &EXPIRES)?; let last_modified = get_header(headers, &LAST_MODIFIED)?; - let content_type = response - .headers() + let content_type = headers .get(CONTENT_TYPE) .map(|c| c.to_str().map_err(FromHttpResponseError::::from)) .transpose()?