You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
annoying
this feature was working in a previous version but is broken in the current release.
Bruno version
3.5.1
Operating System
Windows 11 Enterprise 26100.8655
Describe the bug
I'm attempting to set variable values in a request onFail() handler. Demo Collection attached. It has to be in Developer mode.
If I retrieve and log the value in the onFail function, the set value is shown. When a subsequent request is run, that value has been lost and the value set in the main body of the pre-request script is shown.
I was initially running this with just setEnvVar/getEnvVar, but expanded it to include setVar/getVar and setGlobalEnvVar/getGlobalEnvVar. The global var's value isn't just not updated in onFail, the variable seems to be completely lost ("null" in subsequent request).
Steps to reproduce
Import the attached collection
Open dev tools so console is shown
Send the My.GetEnhancedSecurityKey request to override the value of the enhanced_security_key_env environment value. Provide any value, doesn't matter.
Send the My.ShowEnhancedSecurityKey request
Log will show the variable being set, being overridden succesfully in the Get request's prerequest script req.onFail function, then the Show request will show that the value was lost and the variable reverted to the value set in the Set req prerequest main body.
Collection to reproduce
I've been blocked from uploading a tgz by the corporate overlords. It's a short collection, I'm pasting the contents of the whole collection below. I know that's a PITA, thanks for tolerating it. My format is:
#####
# file_name_here
#####
file_contents_here
$ while read f ; do echo "#####"; echo "# $f "; echo "#####"; cat $f; done < <(find . -type f)
./environments/env.yml
name: env
variables:
name: enhanced_security_token_env
value: Value from environment file
http:
method: GET
url: http://127.0.0.1:9999
body:
type: text
data: "Value from body prompt, set in req.onFail(): {{?Enter a value}}"
runtime:
scripts:
- type: before-request
code: |-
bru.setVar("enhanced_security_token_runtime", "Set in main body of pre-request script");
bru.setEnvVar("enhanced_security_token_env", "Set in main body of pre-request script");
bru.setGlobalEnvVar("enhanced_security_token_global", "Set in main body of pre-request script");
console.log("main body of pre-request script enhanced_security_token_runtime = ",bru.getVar("enhanced_security_token_runtime"));
console.log("main body of pre-request script enhanced_security_token_env = ",bru.getEnvVar("enhanced_security_token_env"));
console.log("main body of pre-request script enhanced_security_token_global = ",bru.getGlobalEnvVar("enhanced_security_token_global"));
req.onFail(() => {
const bdy = req.getBody();
bru.setVar("enhanced_security_token_runtime", bdy);
bru.setEnvVar("enhanced_security_token_env", bdy);
bru.setGlobalEnvVar("enhanced_security_token_global", bdy);
console.log("in onFail() enhanced_security_token_runtime = ",bru.getVar("enhanced_security_token_runtime"));
console.log("in onFail() enhanced_security_token_env = ",bru.getEnvVar("enhanced_security_token_env"));
console.log("in onFail() enhanced_security_token_global = ",bru.getGlobalEnvVar("enhanced_security_token_global"));
});
I have checked the following:
This bug is:
Bruno version
3.5.1
Operating System
Windows 11 Enterprise 26100.8655
Describe the bug
I'm attempting to set variable values in a request onFail() handler. Demo Collection attached. It has to be in Developer mode.
If I retrieve and log the value in the onFail function, the set value is shown. When a subsequent request is run, that value has been lost and the value set in the main body of the pre-request script is shown.
I was initially running this with just setEnvVar/getEnvVar, but expanded it to include setVar/getVar and setGlobalEnvVar/getGlobalEnvVar. The global var's value isn't just not updated in onFail, the variable seems to be completely lost ("null" in subsequent request).
Steps to reproduce
Log will show the variable being set, being overridden succesfully in the Get request's prerequest script req.onFail function, then the Show request will show that the value was lost and the variable reverted to the value set in the Set req prerequest main body.
Collection to reproduce
I've been blocked from uploading a tgz by the corporate overlords. It's a short collection, I'm pasting the contents of the whole collection below. I know that's a PITA, thanks for tolerating it. My format is:
$ while read f ; do echo "#####"; echo "# $f "; echo "#####"; cat $f; done < <(find . -type f)
./environments/env.yml
name: env
variables:
value: Value from environment file
./My.GetEnhancedSecurityToken.yml
info:
name: My.GetEnhancedSecurityToken
type: http
seq: 3
http:
method: GET
url: http://127.0.0.1:9999
body:
type: text
data: "Value from body prompt, set in req.onFail(): {{?Enter a value}}"
runtime:
scripts:
- type: before-request
code: |-
bru.setVar("enhanced_security_token_runtime", "Set in main body of pre-request script");
bru.setEnvVar("enhanced_security_token_env", "Set in main body of pre-request script");
bru.setGlobalEnvVar("enhanced_security_token_global", "Set in main body of pre-request script");
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
./My.ShowEnhancedSecurityToken.yml
info:
name: My.ShowEnhancedSecurityToken
type: http
seq: 1
http:
method: GET
url: http://127.0.0.1:9999
body:
type: text
data: asdf
runtime:
scripts:
- type: before-request
code: |-
console.log("In subsequent request, enhanced_security_token_runtime = ",bru.getVar("enhanced_security_token_runtime"));
console.log("In subsequent request, enhanced_security_token_env = ",bru.getEnvVar("enhanced_security_token_env"));
console.log("In subsequent request, enhanced_security_token_global = ",bru.getGlobalEnvVar("enhanced_security_token_global"));
settings:
encodeUrl: true
timeout: 0
followRedirects: true
maxRedirects: 5
./opencollection.yml
opencollection: 1.0.0
info:
name: IssueDemo
bundled: false
extensions:
bruno:
ignore:
- node_modules
- .git
Screenshots/Live demo link
Recording.2026-07-10.160603.mp4