fix: Improve edge extraction validation checks

- Add explicit check for empty nodes list
- Use more explicit 0 <= idx comparison instead of -1 < idx
- Prevents nonsensical error message when no entities provided
This commit is contained in:
Daniel Chalef 2025-10-02 16:32:08 -07:00
parent 87cb95e24d
commit 4f0743f4bc

View file

@ -179,7 +179,12 @@ async def extract_edges(
source_node_idx = edge_data.source_entity_id
target_node_idx = edge_data.target_entity_id
if not (-1 < source_node_idx < len(nodes) and -1 < target_node_idx < len(nodes)):
if len(nodes) == 0:
logger.warning('No entities provided for edge extraction')
continue
if not (0 <= source_node_idx < len(nodes) and 0 <= target_node_idx < len(nodes)):
logger.warning(
f'Invalid entity IDs in edge extraction for {edge_data.relation_type}. '
f'source_entity_id: {source_node_idx}, target_entity_id: {target_node_idx}, '