Skip to content

Handle circular dependencies - #1858

Closed
Ryan Brandenburg (ryanbrandenburg) wants to merge 1 commit into
mainfrom
rybrande/conda_overflow
Closed

Handle circular dependencies#1858
Ryan Brandenburg (ryanbrandenburg) wants to merge 1 commit into
mainfrom
rybrande/conda_overflow

Conversation

@ryanbrandenburg

Copy link
Copy Markdown
Contributor

As-is it's possible to get stuck in a look when A->B->A (Or A->B->C->A, etc) which eventually causes a stack-overflow. This PR adds a set to keep track of visited packages so we can be sure we never end up in a loop. Before the fix the unit test I added would crash the test-host. I also checked the fix against the real-world report which alerted me to this issue.

Copilot AI lite review requested due to automatic review settings August 19, 2026 21:08
@github-actions

Copy link
Copy Markdown

👋 Hi! It looks like you modified some files in the Detectors folder.
You may need to bump the detector versions if any of the following scenarios apply:

  • The detector detects more or fewer components than before
  • The detector generates different parent/child graph relationships than before
  • The detector generates different devDependencies values than before

If none of the above scenarios apply, feel free to ignore this comment 🙂

@ryanbrandenburg

Copy link
Copy Markdown
Contributor Author

Closing this in favor of #1857 (review)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens the Conda lock dependency graph construction against circular dependency chains (e.g., A→B→A) to prevent unbounded recursion and stack overflows during detection.

Changes:

  • Add a visited set to stop recursive dependency traversal from looping indefinitely in CondaDependencyResolver.
  • Add a unit test covering a minimal circular dependency case in a conda-lock.yml input.
Show a summary per file
File Description
test/Microsoft.ComponentDetection.Detectors.Tests/CondaLockComponentDetectorTests.cs Adds a regression test verifying circular dependencies are recorded without crashing.
src/Microsoft.ComponentDetection.Detectors/conda/CondaDependencyResolver.cs Introduces visited-package tracking to prevent recursion loops while building the dependency graph.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +84 to +87
if (!visitedPackages.Add((package.Name, package.Version)))
{
return;
}
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.

2 participants