Use RAII for OpenAPI v2 schema expansion cleanup#8
Open
Copilot wants to merge 3 commits into
Open
Conversation
Agent-Logs-Url: https://github.com/rawkode/kubectl-ditto/sessions/df015851-ebe2-4560-a7f1-7fd01429615c Co-authored-by: rawkode <145816+rawkode@users.noreply.github.com>
Agent-Logs-Url: https://github.com/rawkode/kubectl-ditto/sessions/df015851-ebe2-4560-a7f1-7fd01429615c Co-authored-by: rawkode <145816+rawkode@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor V2 OpenAPI cycle detection to use RAII pattern
Use RAII for OpenAPI v2 schema expansion cleanup
Apr 17, 2026
There was a problem hiding this comment.
Pull request overview
This PR aligns the OpenAPI v2 schema expansion cycle-detection cleanup with the existing v3 approach by using an RAII guard, preventing stale entries in the active “expanding” set on early returns and avoiding subsequent false cycle detection.
Changes:
- Changed
V2Resolver::enterto returnOption<ExpandGuard>(RAII-based tracking) instead of abool. - Removed manual
leavecalls from the v2 field parsing path and relied on guard drop for cleanup. - Added a unit test to ensure the expanding-set entry is cleaned up even when an early return occurs after entering expansion.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The OpenAPI v2 resolver tracked in-progress schema expansion with manual
enter/leavecalls, unlike the v3 path which already used an RAII guard. That left v2 vulnerable to stale entries inexpandingon early return paths, causing false cycle detection on later visits to the same schema.Resolver lifecycle
V2Resolver::enterto return the existingExpandGuardleavehandling from the v2 field parserCycle-detection correctness
expandingRegression coverage