From 230281320759107c0f48dea4c42596991b415ea9 Mon Sep 17 00:00:00 2001 From: Manohar Paturi <186662190+ManoharPaturi@users.noreply.github.com> Date: Thu, 29 Oct 2026 09:14:07 +0530 Subject: [PATCH] FIX: report unknown planned for an empty count combination --- pyrit/analytics/scenario_statistics.py | 8 +++++++- tests/unit/analytics/test_scenario_statistics.py | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/pyrit/analytics/scenario_statistics.py b/pyrit/analytics/scenario_statistics.py index d99867f909..5a21f5c2df 100644 --- a/pyrit/analytics/scenario_statistics.py +++ b/pyrit/analytics/scenario_statistics.py @@ -523,7 +523,13 @@ def combine_execution_counts(counts: Iterable[ScenarioProgressCounts]) -> Scenar return ScenarioProgressCounts( completed=completed, - planned=sum(value for value in planned if value is not None) if all(v is not None for v in planned) else None, + planned=( + # The empty group carries no plan at all, so it reports None rather + # than a vacuous sum() of 0. + sum(value for value in planned if value is not None) + if planned and all(v is not None for v in planned) + else None + ), succeeded=succeeded, success_percentage=success_percentage(succeeded=succeeded, completed=completed), errors=sum(item.errors for item in counts), diff --git a/tests/unit/analytics/test_scenario_statistics.py b/tests/unit/analytics/test_scenario_statistics.py index 1cf5083a08..ff88945392 100644 --- a/tests/unit/analytics/test_scenario_statistics.py +++ b/tests/unit/analytics/test_scenario_statistics.py @@ -142,6 +142,13 @@ def test_combining_count_only_legacy_payloads_does_not_infer_failures_from_histo assert "without an outcome breakdown" in caplog.text +def test_combining_an_empty_group_reports_no_planned_count() -> None: + """An empty display group never learned a plan, so planned is unknown, not 0.""" + combined = combine_execution_counts([]) + assert combined.planned is None + assert combined.completed == 0 + + def test_combining_unequal_scenario_groups_recomputes_both_denominators() -> None: result = make_scenario_result( attack_results={