Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions wasm-wrappers/fdw/cal_fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,13 @@ impl CalFdw {
}
}

// check for errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// transform response to json
let resp_json: JsonValue =
serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

// check for errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// unify response object to array and save source rows
let resp_data = resp_json
.pointer("/data")
Expand Down
6 changes: 3 additions & 3 deletions wasm-wrappers/fdw/calendly_fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ impl CalendlyFdw {
}
}

// check for errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// transform response to json
let resp_json: JsonValue =
serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

// check for errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// unify response object to array and save source rows
let resp_data = if resp_json.pointer("/collection").is_some() {
resp_json
Expand Down
6 changes: 3 additions & 3 deletions wasm-wrappers/fdw/cfd1_fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,13 +226,13 @@ impl Cfd1Fdw {
continue;
}

// check for HTTP errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// transform response to json
let resp_json: JsonValue =
serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

// check for HTTP errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// check for API request errors
if let Some(success) = resp_json["success"].as_bool() {
if !success {
Expand Down
23 changes: 13 additions & 10 deletions wasm-wrappers/fdw/notion_fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,20 +245,23 @@ impl NotionFdw {
}
}

// check for errors
if resp.status_code == 404 {
// if the 404 is caused by no object found, we shouldn't take it as an error
if let Ok(resp_json) = serde_json::from_str::<JsonValue>(&resp.body) {
if resp_json.pointer("/code").and_then(|v| v.as_str())
== Some("object_not_found")
{
break;
}
}
}
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// transform response to json
let resp_json: JsonValue =
serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

// if the 404 is caused by no object found, we shouldn't take it as an error
if resp.status_code == 404
&& resp_json.pointer("/code").and_then(|v| v.as_str()) == Some("object_not_found")
{
break;
}

// check for errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// unify response object to array and save source rows
let resp_data = if resp_json.pointer("/object").and_then(|v| v.as_str()) == Some("list")
{
Expand Down
22 changes: 13 additions & 9 deletions wasm-wrappers/fdw/paddle_fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,23 @@ impl PaddleFdw {
body: String::default(),
};
let resp = http::get(&req)?;
let resp_json: JsonValue = serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

// if the 404 is caused by no object found, we shouldn't take it as an error
if resp.status_code == 404 && resp_json.pointer("/error/code") == Some(&json!("not_found"))
{
self.src_rows = Vec::default();
self.src_idx = 0;
self.url = None;
return Ok(());
// check for errors
if resp.status_code == 404 {
// if the 404 is caused by no object found, we shouldn't take it as an error
if let Ok(resp_json) = serde_json::from_str::<JsonValue>(&resp.body) {
if resp_json.pointer("/error/code") == Some(&json!("not_found")) {
self.src_rows = Vec::default();
self.src_idx = 0;
self.url = None;
return Ok(());
}
}
}

http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

let resp_json: JsonValue = serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

// save source rows
self.src_rows = resp_json
.as_object()
Expand Down
6 changes: 5 additions & 1 deletion wasm-wrappers/fdw/snowflake_fdw/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ impl SnowflakeFdw {
http::Method::Post => http::post(&req),
_ => unreachable!(),
}?;

// Check for errors
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

let json_value = serde_json::from_str(&resp.body).map_err(|e| e.to_string())?;

stats::inc_stats(FDW_NAME, stats::Metric::BytesIn, resp.body.len() as i64);
Expand Down Expand Up @@ -213,7 +217,7 @@ impl SnowflakeFdw {

// polling query result
loop {
http::error_for_status(&resp)?;
http::error_for_status(&resp).map_err(|err| format!("{}: {}", err, resp.body))?;

// make sure response status code is 200 or 202 only
if resp.status_code != 200 && resp.status_code != 202 {
Expand Down