bruno icon indicating copy to clipboard operation
bruno copied to clipboard

Bruno can't access to collection level variables in Safe mode.

Open SPIRIT-00 opened this issue 1 year ago • 7 comments

I have checked the following:

  • [X] I use the newest version of bruno.
  • [X] I've searched existing issues and found nothing related to my issue.

Describe the bug

Bruno can't access to collection level variables in Safe mode. I guess it is.

.bru file to reproduce the bug

No response

Screenshots/Live demo link

Failed GET request изображение Collection level variable is defined изображение

In Dev mod all fine изображение

SPIRIT-00 avatar Aug 21 '24 16:08 SPIRIT-00

Thanks for reporting the issue @SPIRIT-00 We are taking a look at it.

helloanoop avatar Aug 22 '24 08:08 helloanoop

@SPIRIT-00 IN the screenshot you shared, the api url in the first screenshot is different compared to the API in the second screenshot.

Are you using scripting to update the API endpoint? Also are you using external npm modules in the collection (Safe mode does not support loading external modules)

helloanoop avatar Aug 22 '24 09:08 helloanoop

@SPIRIT-00 IN the screenshot you shared, the api url in the first screenshot is different compared to the API in the second screenshot.

Are you using scripting to update the API endpoint? Also are you using external npm modules in the collection (Safe mode does not support loading external modules)

I use this pre-req script to set Endpoint. It takes request level variables and redefine url. Endpoint path on screen broken because scripts can't get collection and local variables values.

// url эндпоинта. const isLink = bru.getRequestVar('isLink'), url = req.getUrl(), testField = bru.getRequestVar('testField'), findOneId = bru.getRequestVar('findOneId'), tooLongId = bru.getRequestVar('tooLongId'), notExistId = bru.getRequestVar('notExistId'), propName = bru.getRequestVar('propName'), propValue = bru.getRequestVar('propValue'), id1 = bru.getRequestVar('id1'), id2 = bru.getRequestVar('id2'); let targetUrl = ``, body = req.getBody();

if (isLink) { targetUrl = /{{table}}/${id1}/{{linkWith}}/${id2}; } else { switch (req.method) { case 'POST': targetUrl = /{{table}}; break default: targetUrl = /{{table}}/${findOneId}; break } } req.setUrl(url + targetUrl);

изображение

SPIRIT-00 avatar Aug 22 '24 09:08 SPIRIT-00

Thanks for sharing this @SPIRIT-00 ! An issue related to getRequestVar api was also fixed in v1.26.1

Can you check if it solves your issue?

helloanoop avatar Aug 22 '24 09:08 helloanoop

@helloanoop i think it issue solved. Request level vars values can be received. But need create new issue about returned datatype of boolean values from request level vars. As can tou see on screenshots in dev mode boolean like values returns as boolean. In safe mode boolean like values returns as strings.

SPIRIT-00 avatar Aug 23 '24 06:08 SPIRIT-00