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

How does Bruno (un)set variables? (checkbox+getVar) #691

Open
jjmonsalveg opened this issue Oct 20, 2023 · 2 comments
Open

How does Bruno (un)set variables? (checkbox+getVar) #691

jjmonsalveg opened this issue Oct 20, 2023 · 2 comments

Comments

@jjmonsalveg
Copy link

It is possible that my interpretation is incorrect but in which case I would like to understand how the following feature works.

If we go to the Vars section we can define the variables and their values.

In js scripts, we should be able to access these variables/values using getVar

So far so good. However, when unchecking the vars section of the checkbox, my expectation is that the script cannot obtain the value of the variable because in theory the checkbox is unchecked, but even so getVar can continue obtaining the value even if it is not checked. This only happens once you check it and uncheck it, the value remains set forever until you restart Bruno and try again first unchecking the getVar checkbox will say null.

From my point of view, unchecking the checkbox means that the value is cleared(null or even not set). Is it a bug? feature? Or misinterpretation on my part?

@jjmonsalveg jjmonsalveg changed the title How does Bruno set variables? How does Bruno (un)set variables? (checkbox+getVar) Oct 20, 2023
@jjmonsalveg
Copy link
Author

I discovered a new comment in the interface

Note: As of today, collection variables can only be set via the API - getVar() and setVar().
In the next release, we will add a UI to set and modify collection variables.

This probably can explain the "expected" behavior which has persistence between calls, and we can check the values in the Variables section. Probably adding a clear or remove button per variable to reset the value could be beneficial

@gagregrog
Copy link

I similarly ran into this and was surprised by it. I interpreted the Vars tab as a request level var since they live within an individual request, but this is just a shortcut to setting a collection level var.

I find this behavior to be unexpected and undesirable. I'd like to be able to set variables that only apply to the given request, yet they apply globally to the entire collection.

I am using a pre-request script to access these vars and am encountering conflicts due to the persistent nature of these bars. Is this always how this feature will behave, or can we expect a change with regard to this? It seems like each scope should be able to have its own vars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants