Skip to content

Comments

fix: recursion detection to allow same resolved $ref in different branches#1241

Open
catosaurusrex2003 wants to merge 4 commits intoasyncapi:masterfrom
catosaurusrex2003:fixes-in-recursion-detection-logic
Open

fix: recursion detection to allow same resolved $ref in different branches#1241
catosaurusrex2003 wants to merge 4 commits intoasyncapi:masterfrom
catosaurusrex2003:fixes-in-recursion-detection-logic

Conversation

@catosaurusrex2003
Copy link
Contributor

The Problem

The recursion detection algorithm incorrectly throws "too much recursion" errors when the same external $ref appears in multiple branches (e.g. in the schema provided in #1236 c1 and c2 both referencing the same external component).

This happens because the algorithm used a global WeakSet that flagged any object seen before, even if it was in a different branch.

Solution

Replaced global WeakSet tracking with path-based tracking using Set<object>. Each branch now gets its own copy of the path, allowing the same object to appear in different branches while still detecting true circular references.

Key Changes

  • Changed WeakSetSet<object> to enable path copying
  • Renamed visitedvisitedInPath for clarity
  • Create new path copy for each branch instead of sharing global set

Related issue(s)

#1236

@catosaurusrex2003 catosaurusrex2003 changed the title fix: Recursion detection to allow same resolved $ref in different branches fix: recursion detection to allow same resolved $ref in different branches Feb 19, 2026
@sonarqubecloud
Copy link

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