Skip to content

Commit 24fc621

Browse files
Update adapter/rest/src/main.rs
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Raphael Götz <52959657+raphael-goetz@users.noreply.github.com>
1 parent c70fc5d commit 24fc621

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

adapter/rest/src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,20 @@ async fn execute_flow_to_hyper_response(
9292
body: Vec<u8>,
9393
store: Arc<base::store::AdapterStore>,
9494
) -> Response<Full<Bytes>> {
95-
let value: Option<Value> = prost::Message::decode(body.as_slice()).ok();
95+
let value: Option<Value> = if body.is_empty() {
96+
None
97+
} else {
98+
match prost::Message::decode(body.as_slice()) {
99+
Ok(v) => Some(v),
100+
Err(e) => {
101+
log::warn!("Failed to decode request body as protobuf Value: {}", e);
102+
return json_error(
103+
StatusCode::BAD_REQUEST,
104+
"Failed to decode request body as protobuf Value",
105+
);
106+
}
107+
}
108+
};
96109

97110
match store.validate_and_execute_flow(flow, value).await {
98111
Some(result) => {

0 commit comments

Comments
 (0)