From ca3cd1ded55d6d3353bb3bb18526a1a923845143 Mon Sep 17 00:00:00 2001 From: KaifAhmad1 Date: Tue, 17 Feb 2026 14:10:32 +0530 Subject: [PATCH] Fix empty decision_id handling: Ensure consistent UUID generation for boundary cases - Fix add_decision to handle both None and empty string decision_id values - Change from 'decision.decision_id is not None' to 'decision.decision_id' - Ensures empty string decision_id also triggers UUID generation like None - Prevents nodes with empty string keys in the graph - Aligns ContextGraph behavior with Decision model's __post_init__ method - Ensures compliance with PR Rule 3: Robust Error Handling and Edge Case Management - All 62 tests still passing successfully --- semantica/context/context_graph.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/semantica/context/context_graph.py b/semantica/context/context_graph.py index d6ce8def..2eda4d3c 100644 --- a/semantica/context/context_graph.py +++ b/semantica/context/context_graph.py @@ -944,8 +944,9 @@ class ContextGraph: """ from .decision_models import Decision - # Handle empty decision ID by generating UUID only if None (preserve empty string) - node_id = decision.decision_id if decision.decision_id is not None else str(uuid.uuid4()) + # Handle empty decision ID by generating UUID for both None and empty string + # This ensures consistent behavior with Decision model's __post_init__ method + node_id = decision.decision_id if decision.decision_id else str(uuid.uuid4()) # Handle None metadata metadata = decision.metadata or {}