Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Bru files containing multipart-form with json are not loaded #1692

Closed
hhanquez opened this issue Feb 29, 2024 · 6 comments
Closed

[Bug] Bru files containing multipart-form with json are not loaded #1692

hhanquez opened this issue Feb 29, 2024 · 6 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@hhanquez
Copy link

I'm writing requests containing multipart/form with json and files

When bruno is loading the collection, the bru file is not loaded as the body can't be parsed

Exemple of body:

body:multipart-form {
  body: {
    "label": "json",
    "foo": "bar"
  },
  file: @file(/home/myname/file.svg)
}

Error in console:

watcher add: /home/myname/bruno/collection/multipartTest.bru
Error sending from webFrameMain:  Error: Failed to serialize arguments
    at s.send (node:electron/js2c/browser_init:169:631)
    at g.send (node:electron/js2c/browser_init:165:2156)
    at add (/tmp/.mount_bruno_GLHdRM/resources/app.asar/src/app/watcher.js:258:23)
    at FSWatcher.<anonymous> (/tmp/.mount_bruno_GLHdRM/resources/app.asar/src/app/watcher.js:436:34)
    at FSWatcher.emit (node:events:527:28)
    at FSWatcher.emitWithAll (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/index.js:540:8)
    at FSWatcher._emit (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/index.js:632:8)
    at NodeFsHandler._handleFile (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:400:14)
    at NodeFsHandler._addToNodeFs (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:637:21)
(node:25051) UnhandledPromiseRejectionWarning: Error: Line 25, col 5:
  24 |     "foo": "bar"
> 25 |   },
           ^
  26 |   file: @file(/home/myname/file.svg)
Expected ":"
    at parser (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/@usebruno/lang/v2/src/bruToJson.js:567:11)
    at bruToJson (/tmp/.mount_bruno_GLHdRM/resources/app.asar/src/bru/index.js:94:18)
    at add (/tmp/.mount_bruno_GLHdRM/resources/app.asar/src/app/watcher.js:255:19)
    at FSWatcher.<anonymous> (/tmp/.mount_bruno_GLHdRM/resources/app.asar/src/app/watcher.js:436:34)
    at FSWatcher.emit (node:events:527:28)
    at FSWatcher.emitWithAll (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/index.js:540:8)
    at FSWatcher._emit (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/index.js:632:8)
    at NodeFsHandler._handleFile (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:400:14)
    at NodeFsHandler._addToNodeFs (/tmp/.mount_bruno_GLHdRM/resources/app.asar/node_modules/chokidar/lib/nodefs-handler.js:637:21)
(node:25051) 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: 6)

Tested on versions 1.9.0 and 1.10.0

@LucaRed
Copy link

LucaRed commented Apr 3, 2024

Still present on v1.12.3. This bug bit me after importing a big collection from Insomnia :-S

Example body:

meta {
  name: Test
  type: http
  seq: 7
}

post {
  url: {{host}}/api/test
  body: multipartForm
  auth: none
}

headers {
  Accept: application/json, text/plain, */*
  Content-Type: application/json
}

body:multipart-form {
  city: {
    "name": "Test",
    "description": "Test"
  }
}

@sanjai0py sanjai0py added the bug Something isn't working label Apr 4, 2024
@sanjai0py sanjai0py added the help wanted Extra attention is needed label Apr 11, 2024
@fskexp
Copy link

fskexp commented May 2, 2024

Hi, a workaround could be to minify your JSON so it fits on a single line (worked for me).

@sanjai0py
Copy link
Collaborator

This bug has been fixed #2086. Please try the latest version of Bruno!

@hhanquez
Copy link
Author

hhanquez commented Jun 6, 2024

Sorry @sanjai0py but I still have the issue on version 1.18.0

This is a test file:

meta {
  name: Test of issue 1692
  type: http
  seq: 3
}

post {
  url: https://www.test.com
  body: multipartForm
  auth: none
}

body:multipart-form {
  body: {
      "label": "json",
      "foo": "bar"
    }
  file: @file(/home/myplace/Images/gif/OuEmkXe.gif)
}

The file is not loaded and I see this in the logs:

(node:242998) UnhandledPromiseRejectionWarning: Error: Line 17, col 6:
  16 |       "foo": "bar"
> 17 |     }
            ^
  18 |   file: @file(/home/myplace/Images/gif/OuEmkXe.gif)
Expected ":"
    at parser (/opt/Bruno/resources/app.asar/node_modules/@usebruno/lang/v2/src/bruToJson.js:592:11)
    at bruToJson (/opt/Bruno/resources/app.asar/src/bru/index.js:94:18)
    at add (/opt/Bruno/resources/app.asar/src/app/watcher.js:249:19)
    at FSWatcher.<anonymous> (/opt/Bruno/resources/app.asar/src/app/watcher.js:548:34)
    at FSWatcher.emit (node:events:527: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)
(Use `bruno --trace-warnings ...` to show where the warning was created)
(node:242998) 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: 1)

@sanjai0py
Copy link
Collaborator

sanjai0py commented Jun 6, 2024

Hi @hhanquez the PR #2407 with the fix has been merged. The next outgoing release will fix your problem.

@sanjai0py
Copy link
Collaborator

Closing this issue has been fixed. Thank you for taking the time to report the bug, everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants