From 34ff9caa081597a60969d7dcb3ca00f58415495c Mon Sep 17 00:00:00 2001 From: Mondo Diaz Date: Mon, 2 Feb 2026 20:43:05 -0600 Subject: [PATCH] Fix circular dependency error message to show actual cycle path The error was hardcoding [pkg_key, pkg_key] regardless of actual cycle. Now tracks the path through dependencies to report the real cycle. --- backend/app/dependencies.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/app/dependencies.py b/backend/app/dependencies.py index 13bb686..43a0fd6 100644 --- a/backend/app/dependencies.py +++ b/backend/app/dependencies.py @@ -698,6 +698,8 @@ def resolve_dependencies( # Track visiting/visited for cycle detection visiting: Set[str] = set() visited: Set[str] = set() + # Track the current path for cycle reporting (artifact_id -> pkg_key) + current_path: Dict[str, str] = {} # Resolution order (topological) resolution_order: List[str] = [] @@ -719,8 +721,10 @@ def resolve_dependencies( # Cycle detection (at artifact level) if artifact_id in visiting: - # Build cycle path - raise CircularDependencyError([pkg_key, pkg_key]) + # Build cycle path from current_path + cycle_start = current_path.get(artifact_id, pkg_key) + cycle = [cycle_start, pkg_key] + raise CircularDependencyError(cycle) # Conflict detection - check if we've seen this package before with a different version if pkg_key in version_requirements: @@ -751,6 +755,7 @@ def resolve_dependencies( return visiting.add(artifact_id) + current_path[artifact_id] = pkg_key # Track version requirement if pkg_key not in version_requirements: @@ -807,6 +812,7 @@ def resolve_dependencies( ) visiting.remove(artifact_id) + del current_path[artifact_id] visited.add(artifact_id) # Add to resolution order (dependencies before dependents)