From 714aaf901ec7e04bccfdb4585067014b652d14a1 Mon Sep 17 00:00:00 2001 From: Zwitschi Date: Sat, 24 Oct 2026 20:00:59 +0200 Subject: [PATCH] fix(scan): _db_complete_blocklist must return sets, not lists B001 change caused 'unsupported operand type(s) for -: list and set' during a full consolidated scan: _db_complete_blocklist returned split_cidr_versions() output, which is tuple[list, list], but write_blocklist_report()/blocklist_delta() expect set operands. Return set(v4), set(v6) to match cumulative_blocklist's contract. Reproduced the exact report path with a populated ledger and verified it no longer crashes. --- app/scan/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/scan/__init__.py b/app/scan/__init__.py index 99586ee..b16b70d 100644 --- a/app/scan/__init__.py +++ b/app/scan/__init__.py @@ -63,10 +63,11 @@ def _sync_blocklist_to_db(connected: bool, desired_v4: list[str], def _db_complete_blocklist(desired_v4: list[str], desired_v6: list[str]): """Complete cumulative blocklist from the DB ledger (B001). - Returns ``(complete_v4, complete_v6)`` derived from the active blocklist - ledger plus this scan's newly desired targets (in case the DB write for - this scan has not run yet). Falls back to the git-history reconstruction - when the DB is unavailable, so nothing regresses. + Returns ``(complete_v4, complete_v6)`` as **sets** (same contract as + ``cumulative_blocklist``) derived from the active blocklist ledger plus + this scan's newly desired targets (in case the DB write for this scan has + not run yet). Falls back to the git-history reconstruction when the DB is + unavailable, so nothing regresses. """ try: from ..db import get_connection @@ -77,7 +78,7 @@ def _db_complete_blocklist(desired_v4: list[str], desired_v6: list[str]): active = [] union = set(active) | set(desired_v4) | set(desired_v6) v4, v6 = split_cidr_versions(union) - return v4, v6 + return set(v4), set(v6) @dataclass