Skip to content

Commit

Permalink
anyhow::bail!() when the value returned by a step function does not…
Browse files Browse the repository at this point in the history
… serialize as an object.
  • Loading branch information
jakubadamw committed Nov 2, 2024
1 parent f0f2c29 commit 8e5b486
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ where
context,
serde_json::from_value(value).expect("must succeed"),
);
async { Ok(serde_json::to_value(result.await?).expect("must succeed")) }.boxed_local()
async {
let json_value = serde_json::to_value(result.await?).expect("must succeed");
if !json_value.is_object() && !json_value.is_null() {
anyhow::bail!(
"the result of a step function must be `null` serializable to a JSON value of an object: {json_value:?}"
);
}
Ok(json_value)
}
.boxed_local()
})
}
}
Expand Down

0 comments on commit 8e5b486

Please sign in to comment.