From b1c713ec5c952309a10148fa06e75dad1963cab6 Mon Sep 17 00:00:00 2001 From: osipovartem Date: Thu, 4 Dec 2025 13:27:03 +0300 Subject: [PATCH 1/2] Take into account query params when singing request --- .../iceberg-rest-catalog/src/apis/fetch.rs | 36 ++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/catalogs/iceberg-rest-catalog/src/apis/fetch.rs b/catalogs/iceberg-rest-catalog/src/apis/fetch.rs index 37aa0b02..e9a9b8c4 100644 --- a/catalogs/iceberg-rest-catalog/src/apis/fetch.rs +++ b/catalogs/iceberg-rest-catalog/src/apis/fetch.rs @@ -31,12 +31,25 @@ where let uri = uri_base + uri_str; let mut req_builder = client.request(method.clone(), &uri); + for (key, value) in query_params.unwrap_or_default() { + req_builder = req_builder.query(&[(key, value)]); + } + if let Some(ref aws_v4_key) = configuration.aws_v4_key { let body_str = match serde_json::to_value(&request) { Ok(serde_json::Value::Null) => "", _ => &serde_json::to_string(&request).expect("param should serialize to string"), }; - let new_headers = match aws_v4_key.sign(&uri, method.as_str(), body_str) { + let uri_for_signing = match req_builder.try_clone() { + Some(cloned_builder) => { + match cloned_builder.build() { + Ok(tmp_req) => tmp_req.url().as_str().to_string(), + Err(_) => uri.clone(), + } + } + None => uri.clone(), + }; + let new_headers = match aws_v4_key.sign(&uri_for_signing, method.as_str(), body_str) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; @@ -56,9 +69,6 @@ where for (key, value) in headers.unwrap_or_default() { req_builder = req_builder.header(key, value); } - for (key, value) in query_params.unwrap_or_default() { - req_builder = req_builder.query(&[(key, value)]); - } if let &reqwest::Method::POST | &reqwest::Method::PUT = &method { req_builder = req_builder.json(request); } @@ -108,12 +118,25 @@ where let uri = uri_base + uri_str; let mut req_builder = client.request(method.clone(), &uri); + for (key, value) in query_params.unwrap_or_default() { + req_builder = req_builder.query(&[(key, value)]); + } + if let Some(ref aws_v4_key) = configuration.aws_v4_key { let body_str = match serde_json::to_value(&request) { Ok(serde_json::Value::Null) => "", _ => &serde_json::to_string(&request).expect("param should serialize to string"), }; - let new_headers = match aws_v4_key.sign(&uri, method.as_str(), body_str) { + let uri_for_signing = match req_builder.try_clone() { + Some(cloned_builder) => { + match cloned_builder.build() { + Ok(tmp_req) => tmp_req.url().as_str().to_string(), + Err(_) => uri.clone(), + } + } + None => uri.clone(), + }; + let new_headers = match aws_v4_key.sign(&uri_for_signing, method.as_str(), body_str) { Ok(new_headers) => new_headers, Err(err) => return Err(Error::AWSV4SignatureError(err)), }; @@ -133,9 +156,6 @@ where for (key, value) in headers.unwrap_or_default() { req_builder = req_builder.header(key, value); } - for (key, value) in query_params.unwrap_or_default() { - req_builder = req_builder.query(&[(key, value)]); - } if let &reqwest::Method::POST | &reqwest::Method::PUT = &method { req_builder = req_builder.json(request); } From b161a6afa54f25e0f49d129e3de4f3810e6de681 Mon Sep 17 00:00:00 2001 From: osipovartem Date: Thu, 4 Dec 2025 13:46:59 +0300 Subject: [PATCH 2/2] Take into account query params when singing request --- .../iceberg-rest-catalog/src/apis/fetch.rs | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/catalogs/iceberg-rest-catalog/src/apis/fetch.rs b/catalogs/iceberg-rest-catalog/src/apis/fetch.rs index e9a9b8c4..9e4610b6 100644 --- a/catalogs/iceberg-rest-catalog/src/apis/fetch.rs +++ b/catalogs/iceberg-rest-catalog/src/apis/fetch.rs @@ -41,12 +41,10 @@ where _ => &serde_json::to_string(&request).expect("param should serialize to string"), }; let uri_for_signing = match req_builder.try_clone() { - Some(cloned_builder) => { - match cloned_builder.build() { - Ok(tmp_req) => tmp_req.url().as_str().to_string(), - Err(_) => uri.clone(), - } - } + Some(cloned_builder) => match cloned_builder.build() { + Ok(tmp_req) => tmp_req.url().as_str().to_string(), + Err(_) => uri.clone(), + }, None => uri.clone(), }; let new_headers = match aws_v4_key.sign(&uri_for_signing, method.as_str(), body_str) { @@ -128,12 +126,10 @@ where _ => &serde_json::to_string(&request).expect("param should serialize to string"), }; let uri_for_signing = match req_builder.try_clone() { - Some(cloned_builder) => { - match cloned_builder.build() { - Ok(tmp_req) => tmp_req.url().as_str().to_string(), - Err(_) => uri.clone(), - } - } + Some(cloned_builder) => match cloned_builder.build() { + Ok(tmp_req) => tmp_req.url().as_str().to_string(), + Err(_) => uri.clone(), + }, None => uri.clone(), }; let new_headers = match aws_v4_key.sign(&uri_for_signing, method.as_str(), body_str) {