bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Generate Code doesn't pickup body changes until saved

Open ixje opened this issue 11 months ago • 2 comments

I have checked the following:

  • [x] I have searched existing issues and found nothing related to my issue.

This bug is:

  • [ ] making Bruno unusable for me
  • [ ] slowing me down but I'm able to continue working
  • [x] annoying
  • [ ] this feature was working in a previous version but is broken in the current release.

Bruno version

2.3.0

Operating System

Linux

Describe the bug

I have some requests in a collection that I often refer to as a template to start (debugging) from. One such template is a POST with a JSON body. Whenever I modify a value in the request body and then press Generate Code it does not pickup the changes in the generated code. Instead I first have to save, then press generate. I find this to be inconvenient as I have to overwrite my collection, generate, then undo + save to restore my template to original.

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Image

ixje avatar May 22 '25 09:05 ixje

It also doesn't swap variables for the the values, make the curl somewhat useless if you use them.

curl --request POST \
  --url http://localhost:3000/foo \
  --header 'content-type: application/json' \
  --data '{
  "bar": "{{varBar}}"
}'

it should return

curl --request POST \
  --url http://localhost:3000/foo \
  --header 'content-type: application/json' \
  --data '{
  "bar": "value-of-varBar"
}'

dvictory avatar May 22 '25 10:05 dvictory

I agree, variable rendering could be the best fix, in order to use generated curl

gioacchino-mauro avatar May 22 '25 16:05 gioacchino-mauro

@dvictory @gioacchino-mauro variable interpolation option will be added by this PR https://github.com/usebruno/bruno/pull/4345

Currently code gen is implement on top of the saved request. Let me check with the team and get back to you on that. JIRA

anusree-bruno avatar May 27 '25 12:05 anusree-bruno

@anusree-bruno do you happen to have an update on this? At least hoping to learn if they agree this is unintentional behaviour

ixje avatar Jun 03 '25 13:06 ixje

Hey @ixje, we’re aligned that the desired behavior is to generate code based on the current state of the request, not just the saved version.

anusree-bruno avatar Jun 05 '25 18:06 anusree-bruno

Thank you. Looking forward to the fix

ixje avatar Jun 10 '25 19:06 ixje

I see that this has been fixed from v2.4.0. Attaching a screen recording tested on v2.6.1

https://github.com/user-attachments/assets/74abc55d-8642-4a8a-b5da-84a8bffe1fc2

anusree-bruno avatar Jun 26 '25 12:06 anusree-bruno

I can confirm this is working on 2.6.1

ixje avatar Jun 26 '25 13:06 ixje