Error when importing a YAML collection of a previously exported GraphQL request
See original GitHub issueExpected Behavior
When importing a yaml file containing a collection there should be no error and the requests should contain the same body as the originally exported collection.
Actual Behavior
On our “real” insomnia collection we see an error saying that the import failed with a stack trace in the below example:
We have also created a test collection to try to reproduce the problem. While we haven’t been able to see exactly the same issue, we do see an issue where the collection appears to import correctly, but when looking at the only request in the collection the GraphQL body and query variable sections are blank.
Reproduction Steps
- Create a new collection
- Create a new GraphQL POST request with the following body: graphql body.txt. Note that tabs seem to be important here, hence why I’ve added as a file to make sure it formats correctly.
- Add the following in the variables section: variables.txt
- Export the collection
- Import the collection
- Look at the request inside the collection
Is there an existing issue for this?
- I have searched the issue tracker for this problem.
Additional Information
From what I can tell this appears to be a very specific problem with the formatting of the request. It only happens when the request body is being saved in double quotes, which is forced by the single quotes used inside the variables section.
It seems to be something about the way insomnia wraps the text onto a newline based on the body in a way that didn’t previously happen. There are instances in the collection where we have a tab character split between two lines with the “<newline>” breaker between them.
In the exported collection, the line starts with \t
instead of \\t
as you would expect (and it was previously). I have no idea why our “real” collection errors when the example one doesn’t. But it seems likely that it has the same root cause, especially since I can see the same weird thing when looking directly at the yaml file.
Note that I’m on a mac, but other members of the team have replicated on windows.
Exported example collection for reference: insomnia.example.yaml.txt
Insomnia Version
v2022.3.0
What operating system are you using?
macOS
Operating System Version
macOs Monterey 12.3.1
Installation method
Downloaded from insomnia.net
Last Known Working Insomnia version
v2022.2.1
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:5 (2 by maintainers)
I’ve solved it by manually editing the yaml file and removed the request body for several requests until the yaml syntax was valid again (by prettier).
Looks like the export functionality is generating broken yaml, and the import is working fine.
Hi, this might be related to #4905, because I have both issues at the same time. Just cross posting comments.