usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
25.67k stars 1.17k forks source link

CURL Import generates invalid bru #3156

Open captn3m0 opened 6 days ago

captn3m0 commented 6 days ago

I have checked the following:

Describe the bug

Importing a specific curl command into bruno fails without an error message. On checking the logs, it appears that the generated bru file is invalid, and the parser fails to parse it.

CURL Command:

curl 'https://x2qnegor.apicdn.sanity.io/v2024-09-06/data/query/production?query=*%5B_type+%3D%3D+%22event%22%5D%7B%0A++++++++_id%2C%0A++++++++title%2C%0A++++++++date%2C%0A++++++++online_date%2C%0A++++++++director%2C%0A++++++++note%2C%0A++++++++%22theme%22%3A+theme-%3Etheme%2C%0A++++++++%22poster%22%3A+poster.asset-%3Eurl%2C%0A++++++++%22city%22%3A+city-%3E%7Bcity%2C+color%7D%2C%0A++++++++%22location%22%3A+location-%3E%7Bname%2C+url%7D%2C%0A++++++++rsvpLink%0A++++++%7D&returnQuery=false'

This is parsed successfully at https://curlconverter.com/

Bruno 1.29.1 gives the following error:

watcher add: /home/nemo/projects/work/blr.today/kitchensink/.bruno/tpccsa.bru
Error sending from webFrameMain:  Error: Failed to serialize arguments
    at s.send (node:electron/js2c/browser_init:2:89409)
    at _.send (node:electron/js2c/browser_init:2:73857)
    at add (/opt/Bruno/resources/app.asar/src/app/watcher.js:298:23)
    at FSWatcher.<anonymous> (/opt/Bruno/resources/app.asar/src/app/watcher.js:609:34)
    at FSWatcher.emit (node:events:519:28)
    at FSWatcher.emitWithAll (/opt/Bruno/resources/app.asar/node_modules/chokidar/index.js:540:8)
    at FSWatcher._emit (/opt/Bruno/resources/app.asar/node_modules/chokidar/index.js:632:8)
    at NodeFsHandler._handleFile (/opt/Bruno/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:400:14)
    at NodeFsHandler._addToNodeFs (/opt/Bruno/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:637:21)
(node:3353343) UnhandledPromiseRejectionWarning: Error: Line 15, col 15:
  14 |   query: *[_type == "event"]{
> 15 |           _id,
                     ^
  16 |           title,
Expected ":"
    at parser (/opt/Bruno/resources/app.asar/node_modules/@usebruno/lang/v2/src/bruToJson.js:629:11)
    at bruToJson (/opt/Bruno/resources/app.asar/src/bru/index.js:113:18)
    at add (/opt/Bruno/resources/app.asar/src/app/watcher.js:294:19)
    at FSWatcher.<anonymous> (/opt/Bruno/resources/app.asar/src/app/watcher.js:609:34)
    at FSWatcher.emit (node:events:519:28)
    at FSWatcher.emitWithAll (/opt/Bruno/resources/app.asar/node_modules/chokidar/index.js:540:8)
    at FSWatcher._emit (/opt/Bruno/resources/app.asar/node_modules/chokidar/index.js:632:8)
    at NodeFsHandler._handleFile (/opt/Bruno/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:400:14)
    at NodeFsHandler._addToNodeFs (/opt/Bruno/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:637:21)
(node:3353343) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

.bru file to reproduce the bug

meta {
  name: TPCC-sanity
  type: http
  seq: 33
}

get {
  url: https://x2qnegor.apicdn.sanity.io/v2024-09-06/data/query/production?query=*%5B_type+%3D%3D+%22event%22%5D%7B%0A++++++++_id%2C%0A++++++++title%2C%0A++++++++date%2C%0A++++++++online_date%2C%0A++++++++director%2C%0A++++++++note%2C%0A++++++++%22theme%22%3A+theme-%3Etheme%2C%0A++++++++%22poster%22%3A+poster.asset-%3Eurl%2C%0A++++++++%22city%22%3A+city-%3E%7Bcity%2C+color%7D%2C%0A++++++++%22location%22%3A+location-%3E%7Bname%2C+url%7D%2C%0A++++++++rsvpLink%0A++++++%7D&returnQuery=false
  body: none
  auth: none
}

params:query {
  query: *[_type == "event"]{
          _id,
          title,
          date,
          online_date,
          director,
          note,
          "theme": theme->theme,
          "poster": poster.asset->url,
          "city": city->{city, color},
          "location": location->{name, url},
          rsvpLink
        }
  returnQuery: false
}
headers {
}

Screenshots/Live demo link

The browser interaction can be validated at https://tpcc.club/events/