usebruno / bruno

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

Fix for error with params #2448

Closed fgrande closed 1 week ago

fgrande commented 2 weeks ago

Description

This would fix Issue #2439 Looks like "params" property breaks the call, and this is filled with the params.

fgrande commented 1 week ago

Consider those calls

https://spring-boot-test-aplication.herokuapp.com/api/users/findById/:id (set 16 as :id) https://spring-boot-test-aplication.herokuapp.com/api/users/findById/16

The difference between them are the "params" tag in the request.

Request with params :id :

mode: 'none', method: 'GET', url: 'https://spring-boot-test-aplication.herokuapp.com/api/users/findById/16', headers: {}, params: [ { name: 'id', value: '16', enabled: true, type: 'path', uid: '0Ndm3TH0VGhdOE0CgP4f6' } ], responseType: 'arraybuffer', script: {},

Request without param :

mode: 'none', method: 'GET', url: 'https://spring-boot-test-aplication.herokuapp.com/api/users/findById/16', headers: {}, params: [], responseType: 'arraybuffer', script: {}, vars: {}, assertions: [],

As you can see the difference lays in the params property. Since it is already decoded (the request.url is - at this point - already filled with the correct param) we don't need it anymore. And putting it, axios refuse the request because of an exception related to the actual url composed :

_header: 'GET /api/users/findById/16?0[name]=id&0[value]=16&0[enabled]=true&0[type]=path&0[uid]=w4AGcAZKgr0VVwXrnBKt7 HTTP/1.1\r\n' + 'Accept: application/json, text/plain, /\r\n' + 'request-start-time: 1718263487771\r\n' + 'User-Agent: axios/1.6.7\r\n' + 'Accept-Encoding: gzip, compress, deflate, br\r\n' + 'Host: spring-boot-test-aplication.herokuapp.com\r\n' + 'Connection: keep-alive\r\n' + '\r\n',

So, removing the params property, works fine. Maybe is not the cleaner solution, but I can give the idea of what's happening.

Regards FabioG

fgrande commented 1 week ago

Adding test files (related to the issue) BrunoTest.zip

helloanoop commented 1 week ago

Thanks @fgrande for investigating the issue and coming up with the fix.

I feel the code related to deleting the path params is better to be kept inside the configureRequest instead of having it in interpolate vars function. I have asked @sanjai0py to make this change right away in a separate PR.

Closing this PR. Thanks again for your work on this.