Skip to content

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

fix(flows): correct deserialization of ops migration in tests

Steven Enamakele502edfcd9bb
diff --git a/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rs b/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rs
index a67ff4cf1b..6681351da2 100644
--- a/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rs
+++ b/crates/openhuman-core/src/flows/ops_migration_deserialize_tests.rs
@@ -31,10 +31,8 @@ fn migrate_and_deserialize_graph_falls_back_when_no_member_is_at_fault() {
fn migrate_and_deserialize_graph_reports_a_non_object_graph_without_inventing_a_location() {
let err = migrate_and_deserialize_graph(json!("this is a string, not a workflow graph"))
.expect_err("a non-object graph must not deserialize");
+ // A non-object has no member to attribute: retain serde's bare type
+ // diagnostic rather than manufacturing a top-level field/path prefix.
+ assert!(err.starts_with("invalid type: "), "got: {err}");
assert!(!err.contains('['), "got: {err}");
- assert!(
- !err.contains(": invalid") || !err.starts_with("name"),
- "got: {err}"
- );
- assert!(err.contains("invalid type"), "got: {err}");
}
diff --git a/tests/json_rpc_e2e.rs b/tests/json_rpc_e2e.rs
index 9ccd2a574d..cd5557e068 100644
--- a/tests/json_rpc_e2e.rs
+++ b/tests/json_rpc_e2e.rs
@@ -11306,6 +11306,33 @@ async fn json_rpc_flows_validate_reports_warnings_and_errors() {
"an invalid graph reports errors, not warnings"
);
+ // 4. A graph that cannot deserialize must preserve the member location
+ // and serde detail through the JSON-RPC envelope, not only in the
+ // in-process migration helper.
+ let malformed_graph = json!({
+ "inputs": [ { "type": "string" } ]
+ });
+ let validate_malformed = post_json_rpc(
+ &rpc_base,
+ 9504,
+ "openhuman.flows_validate",
+ json!({ "graph": malformed_graph }),
+ )
+ .await;
+ let malformed = peel_logs_envelope(assert_no_jsonrpc_error(
+ &validate_malformed,
+ "flows_validate malformed graph",
+ ));
+ assert_eq!(malformed.get("valid").and_then(Value::as_bool), Some(false));
+ let errors = malformed
+ .get("errors")
+ .and_then(Value::as_array)
+ .expect("errors");
+ assert_eq!(errors.len(), 1, "malformed graph has one parse error");
+ let error = errors[0].as_str().expect("string error");
+ assert!(error.contains("inputs[0]"), "missing member path: {error}");
+ assert!(error.contains("missing field"), "missing serde detail: {error}");
+
api_join.abort();
rpc_join.abort();
}