devhammed / insomnia-plugin-documenter

Export Insomnia workspace HTML documentation.
https://insomnia.rest/plugins/insomnia-plugin-documenter
MIT License
27 stars 2 forks source link

JSON.parse SyntaxError since 1.0.5 #3

Closed jhuet closed 1 year ago

jhuet commented 3 years ago

After upgrading from version 1.0.4 and 1.0.5 I'm getting a JSON.parse SyntaxError when accessing a newly generated documentation. It seems to be related to insomnia.json but all JSON validators I've been using tell me it is valid.

Any clue what could be the problem ? When I get back to 1.0.4 the display of the documentation works fine.

Thanks

devhammed commented 3 years ago

@jhuet Kindly provide the Insomnia.json file here.

jhuet commented 3 years ago

Hello @devhammed, insomnia.json file is the same between both versions.

Here's the insomnia.json.txt file.

Please also find attached the .zip files of both full exports: insomnia-1.0.4.zip, insomnia-1.0.5.zip

{
   "_type":"export",
   "__export_format":4,
   "__export_date":"2021-01-19T08:26:15.602Z",
   "__export_source":"insomnia.desktop.app:v2020.5.2",
   "resources":[
      {
         "_id":"req_d3a7868acd2d4c2baa1808ea1efc49d4",
         "parentId":"fld_99f32bcae3c34cb7b995f62366560549",
         "modified":1611044671451,
         "created":1611044671451,
         "url":"{{ base_url }}/surveys",
         "name":"GetSurveys",
         "description":"",
         "method":"GET",
         "body":{

         },
         "parameters":[

         ],
         "headers":[
            {
               "name":"Admin-Token",
               "value":"{{ administrator.token }}",
               "description":"",
               "id":"pair_d76b9d0a0156442aa58bf141cab64bc2"
            }
         ],
         "authentication":{

         },
         "metaSortKey":-1606833245833,
         "isPrivate":false,
         "settingStoreCookies":true,
         "settingSendCookies":true,
         "settingDisableRenderRequestBody":false,
         "settingEncodeUrl":true,
         "settingRebuildPath":true,
         "settingFollowRedirects":"global",
         "_type":"request"
      },
      {
         "_id":"fld_99f32bcae3c34cb7b995f62366560549",
         "parentId":"fld_4fd02f68cf00457f950610a091b0c7d3",
         "modified":1606836884702,
         "created":1606832899101,
         "name":"Surveys",
         "description":"",
         "environment":{

         },
         "environmentPropertyOrder":null,
         "metaSortKey":-999999975,
         "_type":"request_group"
      },
      {
         "_id":"fld_4fd02f68cf00457f950610a091b0c7d3",
         "parentId":"wrk_a58dbb58449f43928aebb88192101a91",
         "modified":1606836830731,
         "created":1606836830720,
         "name":"Administration",
         "description":"",
         "environment":{

         },
         "environmentPropertyOrder":null,
         "metaSortKey":-1000000000,
         "_type":"request_group"
      },
      {
         "_id":"wrk_a58dbb58449f43928aebb88192101a91",
         "parentId":null,
         "modified":1606832665458,
         "created":1606832590082,
         "name":"Survey",
         "description":"",
         "scope":null,
         "_type":"workspace"
      },
      {
         "_id":"req_e033048f93b84135b613c1c9bb911e24",
         "parentId":"fld_16e8e4700e63418ba935eff07b06d9b4",
         "modified":1608309726232,
         "created":1606833746449,
         "url":"{{ base_url }}/{surveyId}/pages",
         "name":"GetPages",
         "description":"",
         "method":"GET",
         "body":{

         },
         "parameters":[

         ],
         "headers":[
            {
               "name":"Admin-Token",
               "value":"{{ administrator.token }}",
               "description":"",
               "id":"pair_aac4458f06db41858bf2119caa73b16f"
            }
         ],
         "authentication":{

         },
         "metaSortKey":-1606833746449,
         "isPrivate":false,
         "settingStoreCookies":true,
         "settingSendCookies":true,
         "settingDisableRenderRequestBody":false,
         "settingEncodeUrl":true,
         "settingRebuildPath":true,
         "settingFollowRedirects":"global",
         "_type":"request"
      },
      {
         "_id":"fld_16e8e4700e63418ba935eff07b06d9b4",
         "parentId":"fld_4fd02f68cf00457f950610a091b0c7d3",
         "modified":1606836878158,
         "created":1606833742115,
         "name":"Pages",
         "description":"",
         "environment":{

         },
         "environmentPropertyOrder":null,
         "metaSortKey":-1000000025,
         "_type":"request_group"
      },
      {
         "_id":"req_1126487208be4840aa158e73d0c2c58e",
         "parentId":"fld_653a28282362407bb92d5dbf6ea2d172",
         "modified":1611044697399,
         "created":1611044697399,
         "url":"{{ base_url }}/administrator/session",
         "name":"CreateSession",
         "description":"",
         "method":"POST",
         "body":{
            "mimeType":"application/json",
            "text":"{\n\t\"username\": \"{{ administrator.userame }}\",\n\t\"password\": \"{{ administrator.password }}\"\n}"
         },
         "parameters":[

         ],
         "headers":[
            {
               "name":"Content-Type",
               "value":"application/json",
               "id":"pair_730eb2bcd7524a4192df6536e82e5518"
            }
         ],
         "authentication":{

         },
         "metaSortKey":-1606835358452,
         "isPrivate":false,
         "settingStoreCookies":true,
         "settingSendCookies":true,
         "settingDisableRenderRequestBody":false,
         "settingEncodeUrl":true,
         "settingRebuildPath":true,
         "settingFollowRedirects":"global",
         "_type":"request"
      },
      {
         "_id":"fld_653a28282362407bb92d5dbf6ea2d172",
         "parentId":"fld_4fd02f68cf00457f950610a091b0c7d3",
         "modified":1606836872222,
         "created":1606836790274,
         "name":"Session",
         "description":"",
         "environment":{

         },
         "environmentPropertyOrder":null,
         "metaSortKey":-1000000075,
         "_type":"request_group"
      },
      {
         "_id":"env_800ccb2e8347e5b93c470fb4e3762c9fbfd3242e",
         "parentId":"wrk_a58dbb58449f43928aebb88192101a91",
         "modified":1606858393882,
         "created":1606832590172,
         "name":"Base Environment",
         "data":{
            "base_url":"",
            "administrator":{
               "userame":"",
               "password":"",
               "token":""
            }
         },
         "dataPropertyOrder":{
            "&":[
               "base_url",
               "administrator"
            ],
            "&~|administrator":[
               "userame",
               "password",
               "token"
            ]
         },
         "color":null,
         "isPrivate":false,
         "metaSortKey":1606832590172,
         "_type":"environment"
      },
      {
         "_id":"jar_800ccb2e8347e5b93c470fb4e3762c9fbfd3242e",
         "parentId":"wrk_a58dbb58449f43928aebb88192101a91",
         "modified":1606837170275,
         "created":1606832590175,
         "name":"Default Jar",
         "cookies":[
            {
               "key":"PHPSESSID",
               "value":"qb5jd2023s5bjpclv9f3udjbqj",
               "domain":"api.carenity.test7",
               "path":"/",
               "hostOnly":true,
               "creation":"2020-12-01T15:39:30.269Z",
               "lastAccessed":"2020-12-01T15:39:30.269Z",
               "id":"36095498947206206"
            }
         ],
         "_type":"cookie_jar"
      },
      {
         "_id":"spc_d5bd08f434f54e14805db1e120d8337a",
         "parentId":"wrk_a58dbb58449f43928aebb88192101a91",
         "modified":1606832590084,
         "created":1606832590084,
         "fileName":"Insomnia",
         "contents":"",
         "contentType":"yaml",
         "_type":"api_spec"
      },
      {
         "_id":"env_6ee0ecb85e8b4236ae5a9497c2fae807",
         "parentId":"env_800ccb2e8347e5b93c470fb4e3762c9fbfd3242e",
         "modified":1611044461604,
         "created":1606858176670,
         "name":"dev",
         "data":{
            "base_url":"http://api.dev.test7",
            "administrator":{
               "userame":"",
               "password":"",
               "token":""
            }
         },
         "dataPropertyOrder":{
            "&":[
               "base_url",
               "administrator"
            ],
            "&~|administrator":[
               "userame",
               "password",
               "token"
            ]
         },
         "color":null,
         "isPrivate":false,
         "metaSortKey":1606858176670,
         "_type":"environment"
      }
   ]
}
devhammed commented 3 years ago

Hi @jhuet , I was able to reproduce the error :+1:

After investigating the issue, I can see that the error is actually with the latest version of the CLI tool this plugin is based on.

I will open the issue there now and hopefully, I will be able to close it myself or we wait for the author.

You can keep using the 1.0.4 for now, there is no much difference between the two versions except for these:

Screenshot from 2021-01-19 11-36-49

But generating another documentation on my end is working which makes this more strange, it is only having the issue with your insomnia.json file though importing in Insomnia actually works too.

Using JSON.parse() in browser and node consoles also throws the same error.

devhammed commented 3 years ago

Hello @jhuet , I just reverted the documenter files to last stable version pending the wait for the fix...kindly upgrade the documenter plugin from Insomnia Plugins UI.

Screenshot from 2021-02-09 15-16-16

I will also try to look for the fix on my end here because it seems @jozsefsallai is busy with other things.

jhuet commented 3 years ago

Thank you @devhammed, everything looks good on my side now!

Aconitin commented 3 years ago

I still have the same issue under 1.0.8

devhammed commented 3 years ago

I still have the same issue under 1.0.8

Now that is strange!

RobertKlohr commented 2 years ago

I've been using the 2.0.0 plugin for about a year and it has been working until today when I hit what appears to be this old recurring issue. I tested the exported pages in Chromium (Chrome and Edge) and Firefox and all 3 showed the same error. I also pulled some older insomnia.json exports that I new worked before and they also failed. Both the older and current JSON exports pass multiple linters as being valid JSON.

My guess is that a component that is shared between Chromium and Mozilla was updated recently and that is causing a conflict with the JavaScript in the bundle.js file used by the plugin.

Sadly I lack the expertise to further troubleshoot the problem without some guidance on where to look for the root cause.

I have attached the contents of the folder created by the plugin in the hopes the error can be easily reproduced.

apidocs.zip

My environment: Windows 10 Insomnia 2022.2.1 insomnia-plugin-documenter 2.0.0 nginx 1.21.6

Error message in Chromium (exact same message in Chrome and Edge)

SyntaxError: Expected ',' or '}' after property value in JSON at position 17
    at JSON.parse (<anonymous>)
    at Wt.__parseJSON (content.js:16:38)
    at Wt.parse (content.js:52:21)
    at Kt.body (content.js:112:25)
    at cn (Request.svelte:108:38)
    at hn (Request.svelte:107:69)
    at ne (index.mjs:1287:19)
    at new fn (Request.svelte:81:16)
    at Array.xn (Rows.svelte:16:81)
    at En (Rows.svelte:12:12)
(anonymous) @ main.js:35
devhammed commented 2 years ago

@RobertKlohr Kindly give me some time to look into this.

@jsoref Any help here?

jsoref commented 2 years ago

Ummm, why me?

jozsefsallai commented 2 years ago

Ummm, why me?

I think they meant to ping me 😅 Sorry.

I will look into this later too, lots of things changed in Insomnia and the documenter needs a massive refactoring.

RobertKlohr commented 1 year ago

@devhammed, @jozsefsallai, Just checking into see if there is any progress. My current workaround is to keep an old install of Insomnia and Chrome loaded just to run this plug-in, which is worth it due to the time it saves me, but if I could get back to a single instance and not have to copy files around that would be even better!

jozsefsallai commented 1 year ago

@RobertKlohr The rewrite has already started, things will be a lot more modular so I do need a bit of time to get it all right. I cannot give an ETA but I hope I can release the new version soon.

RobertKlohr commented 1 year ago

@jozsefsallai, @devhammed , I think I figured out a solution to some of these problems while the plugin is being re-written. What I did to fix my issues was go to the https://github.com/insodoc/insomnia-documenter repository and used the current 0.5.5 release to update the following 4 files in the plugin directory.

bundle.css bundle.css.map bundle.js bundle.js.map

I also removed a hard-code "/insomnia-documenter" path segment that is present in the data-root attribute in bundle.js.

I have created pull request #11 with the changes.

devhammed commented 1 year ago

@jhuet @RobertKlohr New version released that will hopefully fix this: https://github.com/devhammed/insomnia-plugin-documenter/releases/tag/v2.0.1