Skip to content

Commit 42a7729

Browse files
committed
anyhow::bail!() when the value returned by a step function does not serialize as an object.
1 parent f0f2c29 commit 42a7729

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/workflow.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,16 @@ where
4040
context,
4141
serde_json::from_value(value).expect("must succeed"),
4242
);
43-
async { Ok(serde_json::to_value(result.await?).expect("must succeed")) }.boxed_local()
43+
async {
44+
let json_value = serde_json::to_value(result.await?).expect("must succeed");
45+
if !json_value.is_object() {
46+
anyhow::bail!(
47+
"the result of a step function must be serializable to a JSON value of an object: {json_value:?}"
48+
);
49+
}
50+
Ok(json_value)
51+
}
52+
.boxed_local()
4453
})
4554
}
4655
}

0 commit comments

Comments
 (0)