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

White screen on environment variables page after setting numeric value with bru.setEnvVar #914

Closed
langfeld opened this issue Nov 7, 2023 · 4 comments · Fixed by #1285
Closed

Comments

@langfeld
Copy link

langfeld commented Nov 7, 2023

Description

There seems to be an issue with the Bruno REST client where storing a numeric value using the bru.setEnvVar function causes the Environment Variables overview page to fail to load. The page stays blank until Bruno is restarted. However, when storing a numeric value as a string, this issue does not occur.

Steps to Reproduce

  1. Go to the Script section under Post Response.
  2. Execute the following line of code to set a numeric value:
    bru.setEnvVar("locationId", 123);
  3. Attempt to open the Environment Variables overview page - the issue occurs, the page stays white.
  4. Restart Bruno REST client, repeat step 1.
  5. Execute the following line of code to set a numeric value as a string:
    bru.setEnvVar("locationId", String(123));
  6. Attempt to open the Environment Variables overview page again - this time, the issue does not occur, and the page loads correctly.

Expected Behavior

The Environment Variables overview page should open without issues, showing the list of variables, regardless of whether the value set is numeric or a string.

Actual Behavior

When a numeric value is set with bru.setEnvVar("locationId", 123);, the Environment Variables overview page does not load and remains blank. Only after restarting the Bruno REST client does the page become accessible again. Conversely, setting the value as a string with bru.setEnvVar("locationId", String(123)); does not lead to this issue.

Additional Information

  • Bruno REST client version: v1.1.0 (AppImage)
  • Operating System: Linux Mint

The issue appears to be specific to setting numeric values directly. I have not encountered this problem when setting strings or booleans.

Any assistance in resolving this would be greatly appreciated.

@whoistobias
Copy link

whoistobias commented Nov 8, 2023

I'm able to reproduce this error with 100% consistency on the Windows client.

The console shows an error that says "TypeError: e.split is not a function"

@martinsefcik
Copy link
Contributor

It can be simple fixed on

this.editor.setValue(this.props.value || '');

by converting this.props.value to string if it is not a string. But I think in generally it is a bit more complex issue, because If I am not mistaken Bruno allows to store env variables only as strings in bru file. So in the end this numeric value will be saved as string in bru file and not as number. Probably somebody can expect that if number was stored via setEnvVar, then number should be retrieved if I call getEnvVar for the same variable anytime (e.g. after application restart). And it also doesn't have to be number only, but probably more complex object. What should be done then? Should we convert object to string json representation?

So the main question here is how it should behave and whether there are any plans in future to support storing any kind of values and not only strings in env variables (in bru file).

cc: @helloanoop

@martinsefcik
Copy link
Contributor

Related to #847 and #950

helloanoop added a commit that referenced this issue Dec 27, 2023
…_app_when_set_env

fix(#914): Issue crash app when update environment variable
@helloanoop
Copy link
Contributor

Just merged the fix from @nguyenbavinh-decathlon !

So in the end this numeric value will be saved as string in bru file and not as number.

@martinsefcik This will still get stored as a number in the bru file. Currently bru file doesn't differentiate a string and number, everything is stored in plain text. The type is inferred at the time of loading the file.

how it should behave and whether there are any plans in future to support storing any kind of values and not only strings in env variables (in bru file).

So, as of today, we can only store strings and numbers. Due to the nature of the single line editor, it will hard to support storing arrays or objects.

In the future there is plan to support Nested Environments (#292) where a user can choose to get and set the environment by directly updating the json (in this case the environment will be a json file)

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