Skip to content

fix: validate edge endpoints exist in graph_builder.py dependency_map - #94

Open
ivyw960 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
ivyw960:fix/graph-builder-edge-validation
Open

fix: validate edge endpoints exist in graph_builder.py dependency_map#94
ivyw960 wants to merge 1 commit into
OpenNSWM-Lab:mainfrom
ivyw960:fix/graph-builder-edge-validation

Conversation

@ivyw960

@ivyw960 ivyw960 commented Aug 30, 2026

Copy link
Copy Markdown

GraphBuilder.dependency_map() uses dict.setdefault to register edge endpoints, which silently creates phantom entries when an edge references a node ID that does not exist in the blueprint workflow. Later, refresh_step_statuses tries to look up these phantom parents in step_index and crashes with an uninformative KeyError.

Changes in backend/app/faros/runtime/graph_builder.py:

  • Build a node_ids set from the workflow before iterating edges
  • For each edge, check that both source and target exist in the node set
  • If either is missing, raise ValueError with the offending edge details and node ID(s)
  • Drop the setdefault calls since we now validate before appending

Added backend/tests/test_pr_12_graph_builder_edges.py (5 tests): valid edges produce correct upstream/downstream lists, edges with missing source/target/both raise ValueError, and a no-edge blueprint works cleanly. All tests pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant