Skip to content

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

refactor(flows): improve error handling and context usage

Steven Enamakela4fd60093115
diff --git a/crates/openhuman-core/src/flows/ops/builder_gates.rs b/crates/openhuman-core/src/flows/ops/builder_gates.rs
index 06fd3a9e6f..5d7a0ee6bf 100644
--- a/crates/openhuman-core/src/flows/ops/builder_gates.rs
+++ b/crates/openhuman-core/src/flows/ops/builder_gates.rs
@@ -194,7 +194,10 @@ pub(crate) async fn build_builder_proposal(
let summary = tinyflows::summary::summarize(graph);
let mut warnings = graph_trigger_warnings(graph);
- warnings.extend(graph_wiring_warnings(config, graph).await);
+ match graph_wiring_warnings(ctx, config, graph).await {
+ Ok(found) => warnings.extend(found),
+ Err(error) => tracing::debug!(target: "flows", %error, "[flows] wiring warnings unavailable"),
+ }
// Connector onboarding (Phase 5, item 18): tell the proposal card which
// toolkits this graph needs and whether they're connected, so it can render
// "Connect <toolkit>" CTAs instead of a bare gate error later.
diff --git a/crates/openhuman-core/src/flows/ops/validation.rs b/crates/openhuman-core/src/flows/ops/validation.rs
index 57b5cb203b..bf68aa4fdf 100644
--- a/crates/openhuman-core/src/flows/ops/validation.rs
+++ b/crates/openhuman-core/src/flows/ops/validation.rs
@@ -7,7 +7,7 @@ use tinyflows_bus::{GraphValidation, ImportGraphResult, ValidateGraphRequest};
pub(crate) use tinyflows::compat::UNSUPPORTED_NESTED_CONDITIONAL_FAN_IN;
async fn validate_over_bus(
- _ctx: &DispatchCtx,
+ ctx: &DispatchCtx,
config: &Config,
graph: Value,
) -> Result<GraphValidation, String> {
@@ -160,7 +160,7 @@ pub async fn flows_validate(
/// Imports and validates native or n8n graph JSON through TinyFlows without
/// persisting it.
pub async fn flows_import(
- ctx: &DispatchCtx,
+ _ctx: &DispatchCtx,
config: &Config,
graph_json: Value,
format: Option<String>,
diff --git a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
index 22c0aac43d..3bcf052fa7 100644
--- a/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
+++ b/crates/openhuman-core/src/flows/schemas/handlers/definition.rs
@@ -40,10 +40,11 @@ pub(in crate::flows::schemas) fn handle_validate(
}
pub(in crate::flows::schemas) fn handle_import(
- _ctx: DispatchCtx,
+ ctx: DispatchCtx,
params: Map<String, Value>,
) -> ControllerFuture {
Box::pin(async move {
+ let config = ctx.load_config().await?;
let graph = read_required::<Value>(&params, "graph")?;
let format = params
.get("format")
@@ -51,7 +52,7 @@ pub(in crate::flows::schemas) fn handle_import(
.map(|v| serde_json::from_value::<String>(v.clone()))
.transpose()
.map_err(|e| format!("invalid 'format': {e}"))?;
- to_json(ops::flows_import(graph, format).await?)
+ to_json(ops::flows_import(&ctx, &config, graph, format).await?)
})
}