fix: prune unselected folders from filtered v5 exports#9863
Open
officialasishkumar wants to merge 1 commit intoKong:developfrom
Open
fix: prune unselected folders from filtered v5 exports#9863officialasishkumar wants to merge 1 commit intoKong:developfrom
officialasishkumar wants to merge 1 commit intoKong:developfrom
Conversation
When a user exports a subset of requests from the Scratch Pad or any collection, every folder in the workspace was still embedded in the resulting YAML (including each folder's name and docs). Importing such a file recreated empty folder skeletons and leaked documentation from unrelated areas. Pre-compute the set of folder ancestors for the selected request IDs and drop any request group that is not in that set. Requests and other leaf resources still apply the existing ID filter, so behavior is unchanged when no filter is provided. Closes Kong#9482 Closes Kong#8538
|
|
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.
Summary
When a user exports a subset of requests (for example, a single request from the Scratch Pad), every folder in the workspace was still embedded in the resulting YAML along with each folder's name and docs. Re-importing such a file recreated empty folder skeletons and leaked documentation from unrelated areas of the workspace.
Root cause
In
getInsomniaV5DataExport(packages/insomnia/src/common/insomnia-v5.ts), the filter applied when arequestIdslist is provided short-circuits for everyRequestGroup, so request groups are always included regardless of whether they contain any of the selected requests.Fix
Pre-compute the set of
RequestGroupIDs that are ancestors of at least one selected request, then only emit request groups whose ID is in that set. Non-folder resources still use the existingrequestIds.includes(...)filter. Behavior is unchanged when no filter is supplied.Tests
Two new tests in
packages/insomnia/src/common/__tests__/insomnia-v5.test.tscover:Test plan
npm test -w packages/insomniapasses forsrc/common/__tests__/insomnia-v5.test.ts(21/21, including the 2 new cases).npm run lintpasses.tscreports no new type errors ininsomnia-v5.ts.Closes #9482
Closes #8538