Open tho-gru-38 opened 2 weeks ago
A Bruno run time variable can be altered without using bru.setVar.
In the tests section I have following code:
const request = req.getBody(); bru.setVar("request", request); request.newProp = "Created by Script";
When sending the request the timeline looks good:
But when inspecting the variables the variable was changed:
My idea is that the run time variable request hold the reference to the JavaScript variable. In my opinion the run time variable should be a deep copy of the JavaScript object.
This issue is related to https://github.com/usebruno/bruno/issues/3443 where a deep copy should fix it.
I am not sure if https://github.com/usebruno/bruno/issues/2549 is related too. (strings might be stored as reference too).
meta { name: Modify varaible type: http seq: 7 } get { url: https://jsonplaceholder.org/users body: json auth: none } headers { content-type: application/json } body:json { { "propA": "abc" } } script:pre-request { bru.deleteAllVars(); } tests { const request = req.getBody(); bru.setVar("request", request); request.newProp = "Created by Script"; }
I have checked the following:
Describe the bug
A Bruno run time variable can be altered without using bru.setVar.
In the tests section I have following code:
When sending the request the timeline looks good:
But when inspecting the variables the variable was changed:
My idea is that the run time variable request hold the reference to the JavaScript variable. In my opinion the run time variable should be a deep copy of the JavaScript object.
This issue is related to https://github.com/usebruno/bruno/issues/3443 where a deep copy should fix it.
I am not sure if https://github.com/usebruno/bruno/issues/2549 is related too. (strings might be stored as reference too).
.bru file to reproduce the bug
Screenshots/Live demo link