fix: handle circular OpenAPI schemas during conversion#454
Conversation
|
Warning Review limit reached
More reviews will be available in 14 minutes and 37 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThis PR fixes a stack overflow bug that occurred when converting OpenAPI 3.0.2 documents with self-referencing component schemas. The fix introduces document pruning helpers, restructures the parseOAS pipeline to apply pruning before dereferencing, updates route handling to inline path prefixes, and adds a test case validating the fix works with recursive schema structures. ChangesOpenAPI Self-Referencing Schema Stack Overflow Fix
🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@libs/converter-openapi/src/index.ts`:
- Around line 241-246: The parseOAS implementation eagerly calls
upgrade(content) inside of(...), causing synchronous throws; change it to a lazy
Observable so upgrade(content) runs only on subscription (use RxJS defer or a
deferred factory returning the upgrade result) so errors become Observable
errors; update the pipeline starting at the current
of(upgrade(content).specification) to a deferred Observable that invokes
upgrade(content).specification when subscribed, keeping the downstream
map(dereference(...)) and error path intact (refer to parseOAS and the toADC
call sites to ensure behavior stays consistent).
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 01f7a933-781c-4a95-85c3-ed206230ec3f
📒 Files selected for processing (3)
libs/converter-openapi/src/index.tslibs/converter-openapi/test/assets/basic-8.yamllibs/converter-openapi/test/basic.spec.ts
|
The actionable inline issue from CodeRabbit was fixed in 4294efb and the thread is resolved. I am not adding an API-server E2E for this case because |
Fixes #453.
adc convert openapionly needs routing metadata, but the converter was dereferencing the whole OpenAPI document before conversion. For OpenAPI 3.0 documents with circular component schemas, that can make unrelated schema graphs fail before route conversion.This changes the converter to upgrade the raw spec first, build a conversion-only document containing
info,servers,paths, reusable path items, andx-adc-*fields, then dereference that smaller document. Request and response schema trees are left out because ADC config output does not consume them.Route, service, upstream, label, and plugin metadata conversion behavior is preserved. A regression fixture covers the self-referencing schema from the issue.
Summary by CodeRabbit
Release Notes
Improvements
Tests