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
Bug: Pre-request script is executed before the request is prepared #2249
Comments
The pre-request script phase is now executed after configureRequest. That means the 'req' object in pre-request script has access to more data, including evaluated variables, set authorization headers, etc. fixes usebruno#2249
Hey @pietrygamat We have a fix in place for this, which is planned to be included in the upcoming release. |
Wow :(
For the context - because bruno does not support raw file (and I want some extra control over file selection) I've implemented this script to send raw binary content in post request. few versions ago it was fully functional script, now it's not working at all. Not sure what exactly was broken but errors or console logs from pre-req are not delivered anywhere and this file is not being sent to api eiter Bruno version: 1.17.0 |
@lohxt1 do you have an update on this one, or a public branch where this can be peeked at?
|
I have checked the following:
Describe the bug
When executing the request, bruno goes through several stages of configuration, among them: execution o pre-request script, post-request script, and run of 'configureRequest` method. The current execution order is:
I wonder if it would make more sense to execute the steps in this order:
This way any logic built into bruno may be overwritten by user's script and on top of that, user's script execute on request that is closer to what is actually being sent (e.g. with variables resolved, headers set).
For example, the below bru file logs this to console:
while I would expect the output Before and After to be the same.
.bru file to reproduce the bug
meta {
name: example
type: http
}
post {
url: {{api_url}}
body: text
auth: basic
}
headers {
Content-Type: application/json
}
auth:basic {
username: user
password: password
}
script:pre-request {
console.log('Before');
console.log(req.url);
console.log(JSON.stringify(req.getHeaders()));
}
script:post-response {
console.log('After');
console.log(req.url);
console.log(JSON.stringify(req.getHeaders()));
}
Screenshots/Live demo link
N/A
The text was updated successfully, but these errors were encountered: