fix(overlays): copy update object to avoid applying to references#183
Merged
thim81 merged 1 commit intothim81:mainfrom Dec 14, 2025
Merged
fix(overlays): copy update object to avoid applying to references#183thim81 merged 1 commit intothim81:mainfrom
update object to avoid applying to references#183thim81 merged 1 commit intothim81:mainfrom
Conversation
Owner
|
hi @johncowen Nice catch and great to see that OpenAPI-format is being using within kuma.io (interesting product). I'll try to make some time this weekend to merge the PR and release a new openapi-format version. Let me know, if you run into more issues. |
Owner
|
hi @johncowen I just released openapi-format v1.29.1, which contains your fix for the overlay copy behaviour. Enjoy the new release. |
Contributor
Author
|
Awesome, thanks again @thim81 👍 |
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.
Using OpenAPI overlays, when an
updateapplies to several targets theupdateobject/source is applied by reference to all targets.This means that if you subsequently try to make a further
updateto only one of these targets, this update will be applied to all of the previously applied targets (via the reference)This PR adds a
structuredCloneto theupdateobject which makes a deep copy/clone of it before applying, which I think is the correct fix for the issue. (Note:structuredCloneis available from node 17)I've included a rough reproduction which is the easiest way to see the problem. If you revert the fix I've applied here you will see that the output of the overlay produces something like the following i.e. the second
updateis applied three times.I've also added some comments in the reproduction to help understand the issue, I'd be happy to remove these before merge if you don't want these to stay in there.
Let me know if you have any questions on the above 👍