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
This commit is contained in:
KaifAhmad1
2026-02-17 14:10:32 +05:30
parent e37a54999f
commit ca3cd1ded5
+3 -2
View File
@@ -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 {}