From 56cb388e6110ae0e6c08fd6e0c577cddd0b4db54 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Fri, 9 Oct 2026 19:42:59 +0200 Subject: [PATCH] fix(scans): the overview and target list split an old run's notes too Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p --- compliance-agent/src/api/handlers/health.rs | 7 ++++++- compliance-agent/src/api/handlers/onboarding.rs | 4 +++- compliance-core/src/models/scan.rs | 5 +++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/compliance-agent/src/api/handlers/health.rs b/compliance-agent/src/api/handlers/health.rs index 24f7977..3148ddc 100644 --- a/compliance-agent/src/api/handlers/health.rs +++ b/compliance-agent/src/api/handlers/health.rs @@ -99,7 +99,12 @@ pub async fn stats_overview( .limit(10) .await { - Ok(cursor) => collect_cursor_async(cursor).await, + Ok(cursor) => { + let mut runs: Vec = collect_cursor_async(cursor).await; + // Runs recorded before notes existed list them among their skips. + runs.iter_mut().for_each(ScanRun::split_notes); + runs + } Err(e) => { tracing::warn!("Failed to fetch recent scans: {e}"); Vec::new() diff --git a/compliance-agent/src/api/handlers/onboarding.rs b/compliance-agent/src/api/handlers/onboarding.rs index bc4074d..9cd82a4 100644 --- a/compliance-agent/src/api/handlers/onboarding.rs +++ b/compliance-agent/src/api/handlers/onboarding.rs @@ -200,7 +200,9 @@ pub(crate) async fn latest_scan_runs( cursor .filter_map(|row| async move { let run = row.ok()?.get_document("run").ok()?.clone(); - let run: ScanRun = mongodb::bson::from_document(run).ok()?; + let mut run: ScanRun = mongodb::bson::from_document(run).ok()?; + // Runs recorded before notes existed list them among their skips. + run.split_notes(); Some((run.repo_id.clone(), run)) }) .collect() diff --git a/compliance-core/src/models/scan.rs b/compliance-core/src/models/scan.rs index d3f1420..a955627 100644 --- a/compliance-core/src/models/scan.rs +++ b/compliance-core/src/models/scan.rs @@ -186,8 +186,9 @@ pub struct ScanRun { pub sbom_quality: Option, } -/// Why a stage was skipped, stable for the dashboard to word in the reader's -/// language. The stage's `reason` next to it is English prose for API +/// Why a stage was skipped, or what a run note is about +/// ([`SkipCode::is_informational`]), stable for the dashboard to word in the +/// reader's language. The stage's `reason` next to it is English prose for API /// readers; neither ever carries a server path or a raw error (those go to /// the log). #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)]