-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
fix(#1518) Add support for displaying the response data in the Timeline and improve scripting error handling #1662
base: main
Are you sure you want to change the base?
fix(#1518) Add support for displaying the response data in the Timeline and improve scripting error handling #1662
Conversation
For the discussion. This PR solves the root cause by displaying errors and showing the response in the timeline pane however I have the feeling this can be improved. |
<span className="arrow">{'<'}</span> DATA | ||
</pre> | ||
|
||
<pre className="line response">{responseData}</pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think showing the complete response here is a good idea, without any limitations. Showing bigger responses will cause some massive lag.
Dismissing the error in the response tab would probably be a better idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @Its-treason thanks for taking the time to review my PR
One of the main reason of displaying the raw payload here is that the timeline is considered by many as the "Debugging tab", and is used to check what has been sent and received in a raw/unprocessed manner.
Working in a complex environment (i.e. with cascading gateways) I came across several scenarios where the request was in error but bruno actually received content and I was left with only very little information about the error detail - which was burried inside the response and had to revert to generating the curl command line to find out the issue.
For instance invalid Json, misbehaving APIS returning HTML errors instead of JSON errors etc..
From a UX experience, I think (I might be wrong) that the response tab should be used for successful response only as it allows for further response processing (filtering etc.).
The timeline is a good place for showing the raw network exchanges.
Maybe a good tradeoff would be to only show the unprocessed response data in case of error what do you think ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should responses for certain content types be ignored say images/videos/whatever (allow user to override from some config file?)
Also, allow user to set a limit on the maximum number of bytes that should be processed, if breached, response wont be processed?
May be better options?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having a look at https://www.iana.org/assignments/media-types/media-types.xhtml#application there is no easy way of finding out if the content type is binary or not therefore we would need to support user configurable debuggable payloads (along side to a size limit).
Having a look at this solution
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thekalinga I implemented the discussed idea (PR description is updated see screenshot)
Three new settings have been added to the general preferences tab :
- Display the response in the timeline tab (Yes/No)
- Limit the display to responses which size is lower than the provided threshold (if the user specifies 0 then the setting is ignored and all sizes are considered)
- Limit the display to responses of the corresponding content types, if empty or '*' all the content types will be displayed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fredjeck Thank you. I am not a maintainer on this project. Please note that my understanding of this codebase is extremely limited. However, I will share my comments in few days.
In the interim, here are few comments.
For safety reasons, when user specifies nothing, I tend to be more restrictive rather than less restrictive so as to not run out of memory i.e when no size limit is specified, I would want to restrict to a reasonable size but not unlimited. When they specify no content types, we would ideally want to restrict to a specific known types & if user specifies, we can use those.
Also, I see that the complete response is converted to string before being parsed. We might want to verify content type header to get the number of bytes (or) read raw bytes 1st till we reach the threshold before dropping off the buffer on floor if it overflows user specifies size. Currently we seem to read everything into a simple buffer & also assuming it to be interpreted as a string irrespective of the content-type header sent by server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @thekalinga thanks for your time - I'm also not a maintainer just a user which tries to improve a wonderful tool out of some experiences.
While I tend to agree with you regarding settings, I believe that's what defaults are made for.
I think it is better to let the user in control of his environment - placing predefined defaults which can be overridden if required rather than locking down everything and creating frustrations. That's why the new preferences set do have defaults and can be overridden (like in most software) if needed.
When it come to response parsing the network code was not changed. The data buffer is returned by the electron process along with the response size which is then used to take the decision if the content should or not be rendered, therefore the response buffer is not taken into consideration at this point.
When it comes to parsing the whole goal of the PR is to provide debugging support/insight with raw unmodified content to the user when something goes wrong. As already explained as of today in case of error with actual data returned by remote API you will not see anything and you will have to revert to Curl to check the root cause.
Therefore I voluntarily chose to display the raw unparsed response as a string.
…depending on selected response size and mime types usebruno#1518
Closes #1518
Description
Considering the following valid request which contains a scripting error:
Bruno 1.9 and prior is showing the following response and timeline
![image](https://private-user-images.githubusercontent.com/15845066/307554989-71fd1f1e-07cc-4946-9984-73e982ada646.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAxNTUsIm5iZiI6MTczOTA2OTg1NSwicGF0aCI6Ii8xNTg0NTA2Ni8zMDc1NTQ5ODktNzFmZDFmMWUtMDdjYy00OTQ2LTk5ODQtNzNlOTgyYWRhNjQ2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAyNTczNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTEwYjQwNmRmNTU2Y2Q3MjhhYTYxZDBkMmFmMjQ0MmVhMjhjMjhhYWI4YjNmMThhMWNjMjdiYzk5MTQ4YTQxM2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.mk1FNxFmwg3ReOHnTCOiwLQcAZBW7Bqn9EpMzV7U7tM)
![image](https://private-user-images.githubusercontent.com/15845066/307555007-38d8bad7-26a5-4353-9794-c6b552f2b374.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAxNTUsIm5iZiI6MTczOTA2OTg1NSwicGF0aCI6Ii8xNTg0NTA2Ni8zMDc1NTUwMDctMzhkOGJhZDctMjZhNS00MzUzLTk3OTQtYzZiNTUyZjJiMzc0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAyNTczNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTU4ZmU1ZWIyMjAwNmE4MWI4ODlkZGM4NjY1MTE0MjQzMzEyNzVlOWVlMzNmZTIzODZmMGVhYTlkNzI5M2E4NmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.JzsAhpkQ2YQbEe7fRKEritqv2iYmqqnurVWAHxmYQ6Y)
Whereas the request has been executed successfully the message is not really self explanatory and is hard for the user to understand. In fact a scripting error occured and the user has no way to check to the root cause of the scripting error as the response is nowhere to be seen.
This PR improves error handling during requests execution so that:
For example, the request above is now displayed as following in the timeline:
![image](https://private-user-images.githubusercontent.com/15845066/307555242-c6fd449c-f6b2-4b5f-87e6-35678479e9d2.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAxNTUsIm5iZiI6MTczOTA2OTg1NSwicGF0aCI6Ii8xNTg0NTA2Ni8zMDc1NTUyNDItYzZmZDQ0OWMtZjZiMi00YjVmLTg3ZTYtMzU2Nzg0NzllOWQyLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAyNTczNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTQ3OGFhN2Y1Y2JhYzc4ZGFkZDFmMTBhYWQ1ZTI2MjcxYTZkZDU2YWRmZWIxOGJjN2ZkMDk0ZmM5NjA1YWNiMWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.BvwuhtSvoDgM3F9ipothcVtFGlAo2YmvUYgZOyllKEc)
To limit the potentials lags induced by logging large requests payloads in case of errors, three new user preferences have been introduced :
![image](https://private-user-images.githubusercontent.com/15845066/318135635-89b052bf-098a-4e30-a583-3b2126fe9333.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzAxNTUsIm5iZiI6MTczOTA2OTg1NSwicGF0aCI6Ii8xNTg0NTA2Ni8zMTgxMzU2MzUtODliMDUyYmYtMDk4YS00ZTMwLWE1ODMtM2IyMTI2ZmU5MzMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMDklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjA5VDAyNTczNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTYzNWRlZjAzNWEwYzA5NmY2YWY4NmZkMTMwZmVjMjUxMDEyZjhiN2ZkOGNlMzFkNWNlZGRiMDg0OTRmZDlmYWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.2oqh3FTp77BA9tvJy1R4hGf2c9hG5KDWHF8aHUyXGHM)
Contribution Checklist: