Skip to content

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

fix(flows): log full error chain in boot and TTL sweeps (#6010)

Sagar Kewat82c10b52b62b
diff --git a/src/openhuman/flows/ops_part_08.rs b/src/openhuman/flows/ops_part_08.rs
index 728f4ec124..925fc405a4 100644
--- a/src/openhuman/flows/ops_part_08.rs
+++ b/src/openhuman/flows/ops_part_08.rs
@@ -547,13 +547,13 @@ pub async fn sweep_expired_parked_runs(config: &Config) -> usize {
let swept = match store::expire_parked_runs(config, &cutoff, &now_str, &error_msg) {
Ok(swept) => swept,
Err(e) => {
- tracing::warn!(target: "flows", error = %e, "[flows] parked-run TTL sweep failed (read continues)");
+ tracing::warn!(target: "flows", error = %format_args!("{e:#}"), "[flows] parked-run TTL sweep failed (read continues)");
return 0;
}
};
for (run_id, flow_id) in &swept {
if let Err(e) = store::record_run(config, flow_id, "cancelled") {
- tracing::warn!(target: "flows", run_id, flow_id, error = %e, "[flows] TTL sweep: failed to update flow summary for expired run");
+ tracing::warn!(target: "flows", run_id, flow_id, error = %format_args!("{e:#}"), "[flows] TTL sweep: failed to update flow summary for expired run");
}
// Announce the terminal transition (R-m4). `expire_parked_runs` writes
// the row directly rather than going through `finish_flow_run_row`, so
@@ -619,7 +619,7 @@ pub async fn sweep_orphaned_running_runs_on_boot(config: &Config) -> usize {
let candidates = match store::list_running_run_ids(config, floor) {
Ok(candidates) => candidates,
Err(e) => {
- tracing::warn!(target: "flows", error = %e, "[flows] boot sweep: failed to list running runs (skipping)");
+ tracing::warn!(target: "flows", error = %format_args!("{e:#}"), "[flows] boot sweep: failed to list running runs (skipping)");
return 0;
}
};
@@ -638,7 +638,7 @@ pub async fn sweep_orphaned_running_runs_on_boot(config: &Config) -> usize {
Ok(true) => {
swept += 1;
if let Err(e) = store::record_run(config, &flow_id, "interrupted") {
- tracing::warn!(target: "flows", run_id = %run_id, flow_id = %flow_id, error = %e, "[flows] boot sweep: failed to update flow summary for reconciled run");
+ tracing::warn!(target: "flows", run_id = %run_id, flow_id = %flow_id, error = %format_args!("{e:#}"), "[flows] boot sweep: failed to update flow summary for reconciled run");
}
crate::core::bus::BUS.publish(crate::core::events::DomainEvent::FlowRunFinished {
flow_id: flow_id.clone(),
@@ -652,7 +652,7 @@ pub async fn sweep_orphaned_running_runs_on_boot(config: &Config) -> usize {
tracing::debug!(target: "flows", run_id = %run_id, "[flows] boot sweep: row changed status concurrently — skipped");
}
Err(e) => {
- tracing::warn!(target: "flows", run_id = %run_id, error = %e, "[flows] boot sweep: failed to reconcile running run");
+ tracing::warn!(target: "flows", run_id = %run_id, error = %format_args!("{e:#}"), "[flows] boot sweep: failed to reconcile running run");
}
}
}
diff --git a/src/openhuman/flows/ops_tests_part_12_tests.rs b/src/openhuman/flows/ops_tests_part_12_tests.rs
index 6f5c449a15..0261666f6d 100644
--- a/src/openhuman/flows/ops_tests_part_12_tests.rs
+++ b/src/openhuman/flows/ops_tests_part_12_tests.rs
@@ -631,3 +631,12 @@ async fn boot_sweep_skips_a_run_started_after_the_process_floor() {
"only the prior-process orphan may be reconciled, got {swept}"
);
}
+
+#[test]
+fn sweep_error_formatting_preserves_root_cause() {
+ let inner = std::io::Error::new(std::io::ErrorKind::PermissionDenied, "disk permission denied");
+ let err = anyhow::Error::new(inner).context("Failed to initialize flows schema");
+ let formatted = format!("{err:#}");
+ assert!(formatted.contains("Failed to initialize flows schema"));
+ assert!(formatted.contains("disk permission denied"));
+}