[WORKAROUND] Export/import is implemented as backup/restore and causes loss of data
- Dominant language
- TypeScript
- Stars
- 40k
- Forks
- 2.4k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 61
Description
### Expected Behavior
When the user clicks the _Import from File_ button that is placed contextually in an empty collection, or, likewise, when the user navigates to a collection _Import/Export_ menu selection and selects _Import Data / From File_, this implies that data will be imported into the collection in the current context.
Furthermore, while importing, it's reasonable to expect that Insomnia would warn the user that the data being imported may overwrite parts of the existing collection and whether the user wants to do that, leave new data alone or just abort the import and sort it out manually before attempting another import.
### Actual Behavior
The import functionality in most applications out there implies that some external data will be brought into the application or a different application area and adapted for the importing application or that area.
Insomnia implements Export/Import as if it's a Backup/Restore and ignores contextually-placed import buttons and menus and uses various identifiers saved in the imported file to read data into the original collection. So, from the context, it appears that even though the pop-up said import was successful, nothing was imported.
Behind the scenes, Insomnia reads data into the original collection without any regard to any modifications of that collection and silently wipes out existing data. Given that Insomnia follows the new trend of eliminating explicit load/save functionality, there is absolutely no way to preserve that lost data. It's just gone.
### Reproduction Steps
* Create a test request collection `ABC`. Don't use any actual collections.
* Add a couple of requests.
* Export `ABC` as v4 YAML.
* Rename `ABC` to `XYZ` in collection settings and edit collection description.
* Create an empty collection `EMPTY`
* Within `EMPTY`, click _Import from File_ and select exported YAML for `ABC`.
* A pop-up is presented that the file was imported successfully and gives some stats.
* The collection `EMPTY` remains empty, as if the import fails.
* Switch to the dashboard.
* `XYZ` was reverted to `ABC` by import and the new description and all request modifications are gone.
### Is there an existing issue for this?
- [X] I have searched the [issue tracker](https://www.github.com/Kong/insomnia/issues) for this problem.
### Additional Information
There's a recent issue for this and I apologize for creating this one, but I wanted to provide more context. If you want to close this one as a duplicate, I understand. Here it is:
https://github.com/Kong/insomnia/issues/4246
This issue was created as a result of this discussion with @develohpanda:
https://github.com/Kong/insomnia/issues/4034#issuecomment-988302605
The least Insomnia can do is to compare time stamps and warn the user that the collection that is being restored from exported data has been modified after it was exported. This won't cost much development, but will give people a chance to learn that their data is about to be overwritten.
If you choose to keep current functionality, I suggest to rename it to Backup/Restore because it doesn't have much to do with Export/Import. If you choose to keep Export/Import, which would be desirable, imported data should be adapted for the collection into which it is being imported. This should include importing into other areas, such as importing into the Debug collection of a design document.
### Insomnia Version
2021.6.0
### What operating system are you using?
Windows
### Operating System Version
Windows 10 Pro Version 21H2 build 19044.1387
### Installation method
website download
### Last Known Working Insomnia version
_No response_
Contributor guide
Research direction
Start by reproducing the Import from File flow described for EMPTY and the collection Import/Export menu, then compare the resulting collection with the exported ABC data. The issue is done when importing into a collection preserves existing data, applies the imported data to the current context, and warns before overwriting or aborting. Related issue 4246 may contain the current direction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100