Skip to content

Commit e4efebf

Browse files
thomcc-workCopilot
andauthored
Check that HTTP/HTTP_MULTIPART nodes are *actually* valid.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent dcd046f commit e4efebf

1 file changed

Lines changed: 11 additions & 6 deletions

File tree

src/dsl.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -511,12 +511,17 @@ pub fn with_http_options(fut: &str, options: Option<pgrx::JsonB>) -> String {
511511
pgrx::error!("df.with_http_options(): expected a single HTTP or HTTP_MULTIPART node");
512512
}
513513

514-
let config = node
515-
.query
516-
.as_deref()
517-
.and_then(|query| serde_json::from_str::<serde_json::Value>(query).ok());
518-
if !config.as_ref().is_some_and(serde_json::Value::is_object) {
519-
pgrx::error!("df.with_http_options(): HTTP node config must be a JSON object");
514+
let valid_config = match (node.node_type.as_str(), node.query.as_deref()) {
515+
("HTTP", Some(query)) => {
516+
serde_json::from_str::<crate::types::HttpConfig>(query).is_ok()
517+
}
518+
("HTTP_MULTIPART", Some(query)) => {
519+
serde_json::from_str::<crate::types::MultipartConfig>(query).is_ok()
520+
}
521+
_ => false,
522+
};
523+
if !valid_config {
524+
pgrx::error!("df.with_http_options(): HTTP node config is malformed");
520525
}
521526

522527
if let Some(options) = options {

0 commit comments

Comments
 (0)