usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.6k stars 1.27k forks source link

Bruno CLI variable interpolation in the URL is not working #3455

Open Agagnier35 opened 1 week ago

Agagnier35 commented 1 week ago

I have checked the following:

Describe the bug

The variable interpolation of the URL field is partially working when using the CLI. It always work in the UI though.

Type of variable tested as not working:

Type of variable tested as working:

Bruno CLI version: 1.34.1, but I noticed the issue was already happening in 1.28.0 Bruno UI version: 1.34.2

.bru file to reproduce the bug

meta { name: A sample request with a variable in the URL type: http seq: 1 }

get { url: {{host}}/resource/{{id}} body: none }

vars:pre-request { id: 46345080-3b96-45f0-a3df-d26932233473 }

assert { res.status: eq 200 }

Screenshots/Live demo link

when running with the JSON output you can notice that the "results.request.url" field has the variable template still present.

In the provided bru, if the host is an env variable, and the id a request variable, you would notice that the host would be interpolated properly in the results JSON but the ID would still be the template with the {{}}

ganesh-bruno commented 1 week ago

Hi @Agagnier35,

Thank you for reporting this issue.

Currently, we support all levels of variables in the GUI app, but only a few are supported in the CLI. We're working on adding support for all variable types in the CLI as well.

Agagnier35 commented 1 week ago

Hello, I've kept experimenting to try and find a solution to this issue.

This issue seems to also include pre-request scripts (a simple console.log can prove they are not run in the CLI), and the variable interpolation is straight up not working anywhere except for environment variables.

It seems this PR might be the solution to this issue: https://github.com/usebruno/bruno/pull/3186

IMO, making sure the CLI has the same core as the UI should be a bigger priority for your team. These basic features has not been working since 1.28 (they were working before, I had to upgrade due to the breaking changes made to the variables in the UI)