[bug]: "Error while importing: format not recognized" when importing a single environment
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
When exporting a single environment and then reimporting, the following error shows up:
When exporting all the environments, no errors show up. This works whether all is one or multiple environments.
If you use both export methods in an hoppscotch installation that only has one registered environment, the only difference in the two export files is that the first one contains a JSON object, while the second one contains an array of JSON objects.
Steps to reproduce
- Go to the Environments sidebar
- Select an environment to export
- Click on the kebab menu icon on the right of the environment and select 'Export as JSON'
- Click on the Environment Import/Export button
- Select 'Import from Hoppscotch'
- Select the downloaded file of the environment just exported
- Error appears
Environment
Release
Version
Local
@JoelJacobStephen can you take a look into this?
Hi @crossbone-magister Ensure the JSON file has square brackets at the beginning and end. When exporting, a JSON file is downloaded without square brackets at the beginning and end, so when you try to import the same file, an error occurs.
Hi @DanielAttali, thanks for your reply. I also pointed out the missing square brackets in my original description, though not explicitly:
the only difference in the two export files is that the first one contains a JSON object, while the second one contains an array of JSON objects.
What you are suggesting is what I eventually did to move forward with the import, but it feels like a workaround to me. I believe it would be best for the import and export files to have a consistent format instead of having the user to play around with them to make the import work. What do you think about it?
In any case this is just my personal opinion, it's ultimately up to the hoppscotch team to decide if they consider it an issue and what is the best approach to solve it.
Feels like this is still an issue. I can re-import exported env.json (with 1 environment collection) but if I have another file with the simplest content as below - constantly getting "File format not recognized.". Adding this new environment into the previously exported env.json with existed environment produce same error
[
{
"name": "app",
"variables": [
{
"key": "host",
"value": "http://localhost:8000"
}
]
}
]
Hoppscotch Desktop App v2023.12.1-1
@jamesgeorge007 @amk-dev can you look into this?
Hi @nnmer, I couldn't reproduce the issue with the above environment JSON file.
Adding this new environment into the previously exported env.json with existed environment produce same error.
Can you provide a sample environment JSON file that will help reproduce the issue? Also, can you check if it's reproducible on hoppscotch.io?
@jamesgeorge007 , I've played a bit more, maybe restart of OS and App helped, it does work now. But, I've found that the values in json should not contain numbers as a number, but strings instead. If all values to be converted to strings and updated format to native Hoppscotch - I've managed to import my Postman env. collection.
Thanks for your patience and valuable feedback. This feature has been implemented in the latest release.
Closing this ticket as this feature is now available in the recent version. Feel free to reach out if you encounter any further concerns.
Still getting the same error. from client version and from website.
@aakrem, can you share the steps to reproduce? Possibly a sample environment JSON file.
@jamesgeorge007 sure, it's a JSON format and I am trying to import it from this URL: https://cloud.agenta.ai/api/openapi.json
@jamesgeorge007 any idea if we can solve this soon?
Hi, we'll investigate this and get back.
@aakrem, a CORS error occurs while attempting to fetch from the above URL. We're tracking this internally. In the meantime, you can use an extension that adds the Access-Control-Allow-Origin: * rule to the response header. For instance, Allow CORS: Access-Control-Allow-Origin.
Is there any update on this? This is not just related to CORS. I tried to import a OpenAPI 3.01 JSON file which was saved to disc. Even then this error came. The JSON file was generated automatically by Spring Boot and works with OpenAPI viewer.
Hi @pritammobisoft, can you help with the steps you took and a sample file to reproduce? Please follow the steps here while importing an OpenAPI collection.
Hi @jamesgeorge007 Importing https://cloud.agenta.ai/api/openapi.json from URL is not working in Desktop App (windows v2024.3.0).
Same for me, exports from Postman fail to import The [] trick failed also
(Note managed to get a environment in, but never a collection)
Same issue for me while try to import file http://localhost:8000/openapi.json directly exported from FastAPI swagger.
Same for me, when I try to import from Spring Boot OpenApi Spec !
Same for me, when I try to import from Flask OpenApi Spec.
@jamesgeorge007 @liyasthomas can we reopen this issue ? it looks like it's not solved
We are trying to switch from Insomnia. But For this issue, we got stuck. We identified an interesting thing. The exported json file from insomnia gets imported instantly in the personal workspace.
It doesn't work with the newly created workspace.
I saw the same problem is faced by others. But the issue seems to be closed without any solution. Here is the link to the issue: https://github.com/hoppscotch/hoppscotch/issues/3975
I have checked the network response of the API that is being called. Seems like there is one internal crash. Hope the response below helps to solve the issue
{
"errors": [
{
"message": "PrismaClientKnownRequestError: \nInvalid `tx.teamCollection.create()` invocation in\n/usr/src/app/src/team-collection/team-collection.service.ts:296:55\n\n 293 while (collectionProcessQueue.length > 0) {\n 294 const [parentCollID, coll] = collectionProcessQueue.shift()!;\n 295 \n→ 296 const createdColl = await tx.teamCollection.create(\nTransaction API error: Transaction already closed: Could not perform operation.",
"locations": [
{
"line": 2,
"column": 3
}
],
"path": [
"importCollectionsFromJSON"
],
"extensions": {
"code": "INTERNAL_SERVER_ERROR",
"stacktrace": [
"Error: PrismaClientKnownRequestError: ",
"Invalid `tx.teamCollection.create()` invocation in",
"/usr/src/app/src/team-collection/team-collection.service.ts:296:55",
"",
" 293 while (collectionProcessQueue.length > 0) {",
" 294 const [parentCollID, coll] = collectionProcessQueue.shift()!;",
" 295 ",
"→ 296 const createdColl = await tx.teamCollection.create(",
"Transaction API error: Transaction already closed: Could not perform operation.",
" at throwErr (/usr/src/app/src/utils.ts:22:9)",
" at TeamCollectionResolver.importCollectionsFromJSON (/usr/src/app/src/team-collection/team-collection.resolver.ts:291:32)",
" at target (/usr/src/app/node_modules/@nestjs/core/helpers/external-context-creator.js:74:28)",
" at Object.importCollectionsFromJSON (/usr/src/app/node_modules/@nestjs/core/helpers/external-proxy.js:9:24)"
]
}
}
],
"data": null
}
I saw the same problem is faced by others. But the issue seems to be closed without any solution. Here is the link to the issue: https://github.com/hoppscotch/hoppscotch/issues/3975
Hey @ahsanaasim if its not a problem could you share the file you were using so we can try reproducing the issue out end.
Encountering the same issue cannot share the file since it has company data.
anyone solved this issue???
Dummy fix, but I import with Postman, then dump and re-import into Hoppscotch as the import function for Postman works.
Any status update on this issue? We use .NET Swagger generated specs. same error as everyone else.
Same here. First time trying Hoppscotch and shocked that I can't import an OpenAPI spec.