From b32116945962b67ac11aa299c05cc8417e138bfc Mon Sep 17 00:00:00 2001 From: Nubenetes Bot Date: Fri, 19 Jun 2026 10:44:00 +0200 Subject: [PATCH] fix: NoneType comparison crashes in v2_optimizer, dedup, and news_digest Inventory entries can have stars=null or discovered_at=null. Replace .get("stars", 0) with .get("stars") or 0 in all three modules so that None values are safely coerced to 0/"" before numeric/string comparison. Fixes TypeError crashes in: - v2_optimizer.py:632 _calculate_tags - dedup.py:74,108 title dedup and entry scoring - news_digest.py:322 category pool sorting Co-Authored-By: Claude Sonnet 4.6 --- src/dedup.py | 4 ++-- src/news_digest.py | 4 ++-- src/v2_optimizer.py | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/dedup.py b/src/dedup.py index 62f5d0a3..fe10230d 100644 --- a/src/dedup.py +++ b/src/dedup.py @@ -71,7 +71,7 @@ def find_title_duplicates(inventory: Dict, threshold: float = 0.85) -> List[Tupl norm = normalize_title(title) if len(norm) < 10: continue - entries.append((url, norm, entry.get("stars", 0))) + entries.append((url, norm, entry.get("stars") or 0)) log_event(f"[Dedup] Building title index for {len(entries)} entries...") @@ -105,7 +105,7 @@ def find_title_duplicates(inventory: Dict, threshold: float = 0.85) -> List[Tupl def _entry_score(entry: Dict) -> Tuple: return ( - entry.get("stars", 0), + entry.get("stars") or 0, 1 if entry.get("ai_summary") else 0, 1 if entry.get("hierarchy") else 0, len(entry.get("tags", [])), diff --git a/src/news_digest.py b/src/news_digest.py index 53705118..c45d78e8 100644 --- a/src/news_digest.py +++ b/src/news_digest.py @@ -319,8 +319,8 @@ class NewsDigestEngine: for cat_name, entries in category_pools.items(): entries.sort( key=lambda x: ( - x.get("stars", 0), - x.get("discovered_at", ""), + x.get("stars") or 0, + x.get("discovered_at") or "", ), reverse=True, ) diff --git a/src/v2_optimizer.py b/src/v2_optimizer.py index c2781844..bad9196b 100644 --- a/src/v2_optimizer.py +++ b/src/v2_optimizer.py @@ -629,7 +629,7 @@ class V2VisionEngine: # 1. GitHub Objective Reality (Mandate 43) raw_gh = item.get("gh_stars", 0) gh_stars = int(raw_gh) if str(raw_gh).isdigit() else 0 - curator_stars = int(item.get("stars", 0)) + curator_stars = int(item.get("stars") or 0) if gh_stars > 15000 or curator_stars >= 5: tags.add("[DE FACTO STANDARD]")