bruno icon indicating copy to clipboard operation
bruno copied to clipboard

JSON body is quoted when invalid

Open GregoireBellon opened this issue 10 months ago • 1 comments

I have checked the following:

  • [X] I use the newest version of bruno.
  • [X] I've searched existing issues and found nothing related to my issue.

Describe the bug

Hello,

VERSION : 1.12.3.

When sending a POST request with valid JSON in the body, the body is sent without any modification.

When sending a POST request with invalid JSON in the body, the body is quoted before being sent.

This behavior only occurs when the selected content type is JSON. When sending text, invalid XML or SPARQL, the body is not quoted. There is no indication in the timeline view that the body is quoted.


I'm conscious that I'm complaining that Bruno prevents me from shooting myself in the foot, but I'm working on an API that, for legacy purposes, needs to accept requests containing invalid JSON in the body, and a text/json content type. And I can't test my implementation because of this behavior.

A setting to configure this behavior, and some cues that it happens would be nice.

I would be glad to contribute to fix this issue !

.bru file to reproduce the bug

reproduce-bug.zip

Screenshots/Live demo link

Here are the bodies the requests recieved by a beeceptor endpoint : Capture d'écran 2024-04-09 143041 Capture d'écran 2024-04-09 143059

As you can see, the data section doesn't show that quotes are being added to the request Capture d'écran 2024-04-09 143321 Capture d'écran 2024-04-09 143237

GregoireBellon avatar Apr 09 '24 12:04 GregoireBellon

I'm facing the exact same issue. With Bruno 1.16.1 (desktop, not CLI), I could use in a Pre Request Script req.setBody(Buffer.from("the text")) and the raw value without quotes was sent. With Bruro 1.17 this hack stopped working.

Fabiensk avatar May 15 '24 09:05 Fabiensk

This issue has deteriorated after 1.27.0, Bruno now IMPLICITLY sends quoted requests. image image

zlfn avatar Aug 29 '24 14:08 zlfn

Just merged the PR for this. This should be available in the upcoming v1.29.0 release

helloanoop avatar Sep 05 '24 07:09 helloanoop