Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(flows): cover every arm of the graph error locator

M3gA-Mind5687199a3816
diff --git a/Cargo.lock b/Cargo.lock
index c9e77e61df..0d24759be6 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6877,7 +6877,7 @@ dependencies = [
[[package]]
name = "tinyjuice"
-version = "0.3.1"
+version = "0.3.0"
dependencies = [
"async-trait",
"dirs 7.0.0",
@@ -6897,7 +6897,7 @@ dependencies = [
[[package]]
name = "tinyjuice-bus"
-version = "0.3.1"
+version = "0.3.0"
dependencies = [
"serde",
"serde_json",
diff --git a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs
index 9484f3ef4c..b0b5da715f 100644
--- a/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_migration_and_side_effect_tests.rs
@@ -695,3 +695,100 @@ fn migrate_and_deserialize_graph_does_not_blame_a_node_for_a_top_level_fault() {
"error should still name the offending field, got: {err}"
);
}
+
+/// The member scan covers four arrays, and until now only `nodes` was ever
+/// exercised — the other three arms were unreachable in the test suite while
+/// looking correct by inspection.
+///
+/// Each case supplies a graph whose *only* fault is one member of one array, so
+/// a failure here cannot be the top-level guard firing instead.
+#[test]
+fn migrate_and_deserialize_graph_names_the_member_in_inputs_agents_and_edges() {
+ // `WorkflowInput::name` is required; every other field defaults.
+ let bad_input = json!({
+ "inputs": [ { "type": "string" } ]
+ });
+ let err = migrate_and_deserialize_graph(bad_input).expect_err("input without `name`");
+ assert!(
+ err.starts_with("inputs[0]: "),
+ "expected the inputs arm to name the member, got: {err}"
+ );
+
+ // `AgentDefinition::id` is required — `name` is #[serde(default)] here, so
+ // this is a different required field from the node case on purpose.
+ let bad_agent = json!({
+ "agents": [ { "name": "no id" } ]
+ });
+ let err = migrate_and_deserialize_graph(bad_agent).expect_err("agent without `id`");
+ assert!(
+ err.starts_with("agents[0]: "),
+ "expected the agents arm to name the member, got: {err}"
+ );
+
+ // `Edge::from_node` / `to_node` are required.
+ let bad_edge = json!({
+ "edges": [ { "from_port": "main" } ]
+ });
+ let err = migrate_and_deserialize_graph(bad_edge).expect_err("edge without endpoints");
+ assert!(
+ err.starts_with("edges[0]: "),
+ "expected the edges arm to name the member, got: {err}"
+ );
+}
+
+/// The fallback: the graph's own fields are fine and no member is individually
+/// at fault, yet the parse still fails — here `nodes` is a string rather than an
+/// array, so the member scan has nothing to iterate.
+///
+/// This is the case that must NOT invent a location. Emptying the arrays for
+/// the top-level probe also masks this fault, which is exactly why the bare
+/// message has to survive as the last resort.
+#[test]
+fn migrate_and_deserialize_graph_falls_back_when_no_member_is_at_fault() {
+ let nodes_not_an_array = json!({
+ "name": "valid",
+ "nodes": "this is not an array"
+ });
+
+ let err = migrate_and_deserialize_graph(nodes_not_an_array)
+ .expect_err("a non-array `nodes` must not deserialize");
+
+ assert!(
+ !err.contains("nodes["),
+ "no member is at fault, so none may be named: {err}"
+ );
+ assert!(
+ err.contains("invalid type"),
+ "the original serde detail must survive the fallback: {err}"
+ );
+}
+
+/// A graph that is not a JSON object at all.
+///
+/// `tinyflows::migrate::migrate` passes it through rather than rejecting it —
+/// it reads `schema_version` with `Value::get`, which is `None` on a non-object,
+/// and stamps the version back only `if let Value::Object`. So this reaches the
+/// error path with nothing to probe: no members, and no fields to iterate.
+///
+/// The requirement is negative. There is no location to report, so none may be
+/// invented, and the caller must still get serde's own explanation.
+#[test]
+fn migrate_and_deserialize_graph_reports_a_non_object_graph_without_inventing_a_location() {
+ let not_an_object = json!("this is a string, not a workflow graph");
+
+ let err = migrate_and_deserialize_graph(not_an_object)
+ .expect_err("a non-object graph must not deserialize");
+
+ assert!(
+ !err.contains('['),
+ "nothing can be indexed here, so no index may appear: {err}"
+ );
+ assert!(
+ !err.contains(": invalid") || !err.starts_with("name"),
+ "no field may be named for a value that has no fields: {err}"
+ );
+ assert!(
+ err.contains("invalid type"),
+ "serde's own explanation must survive: {err}"
+ );
+}
diff --git a/vendor/tinyjuice b/vendor/tinyjuice
index 8cae496b13..05ff80d25f 160000
--- a/vendor/tinyjuice
+++ b/vendor/tinyjuice
@@ -1 +1 @@
-Subproject commit 8cae496b13ff213dd5ecd0cf80ca918bb64bd0ec
+Subproject commit 05ff80d25f4e81b7963646edfd4991aabe16dc2c