fix: handle circular OpenAPI schemas during conversion#454
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (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 docstrings
🧪 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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
libs/converter-openapi/src/index.ts (1)
187-199: 💤 Low valueConsider using
forEachinstead ofmapfor mutation-only side effects.The outer
services.map()creates and discards an array since only the in-place mutations matter. UsingforEachwould be more semantically appropriate for side-effect-only iteration.♻️ Suggested refactor
tap((services) => - services.map((service) => { + services.forEach((service) => { if (!service.path_prefix) return service; service.routes = service.routes!.map((route: ADCSDK.Route) => { route.uris = route.uris.map( (uri: string) => `${service.path_prefix}${uri}`, ); return route; }); unset(service, 'path_prefix'); - return service; }), ),🤖 Prompt for 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. In `@libs/converter-openapi/src/index.ts` around lines 187 - 199, Replace the outer services.map() with services.forEach() since the callback only performs mutations (modifying route uris and unsetting path_prefix) and doesn't need to return the array. Update the conditional return statement from return service to just return when path_prefix doesn't exist, and remove the final return service statement at the end of the forEach callback since forEach doesn't use return values for iteration.
🤖 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.
Nitpick comments:
In `@libs/converter-openapi/src/index.ts`:
- Around line 187-199: Replace the outer services.map() with services.forEach()
since the callback only performs mutations (modifying route uris and unsetting
path_prefix) and doesn't need to return the array. Update the conditional return
statement from return service to just return when path_prefix doesn't exist, and
remove the final return service statement at the end of the forEach callback
since forEach doesn't use return values for iteration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 78e9429d-e964-41d7-8eca-693547f27ccf
📒 Files selected for processing (1)
libs/converter-openapi/src/index.ts
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
childrenstructures).