bruno icon indicating copy to clipboard operation
bruno copied to clipboard

fix(#1518) Add support for displaying the response data in the Timeline and improve scripting error handling

Open fredjeck opened this issue 1 year ago • 1 comments

Closes #1518

Description

Considering the following valid request which contains a scripting error:

meta {
  name: HttpBin
  type: http
  seq: 2
}

post {
  url: https://httpbin.org/post
  body: json
  auth: none
}

body:json {
  {  
      "test": "hello Bruno"  
  }  
}

vars:post-response {
  unknown_field: res.body.arguments.unknown_field
}

Bruno 1.9 and prior is showing the following response and timeline image image

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:

  • Nothing is changed when a network error occurs while executing a request
  • The error message displayed in the response pane is improved when a scripting error is raised during pre, post and testing phases
  • A scripting error is not anymore considered as fatal (except for pre-request scripting errors) and the response is being returned to the renderer process
  • The full response body is now logged into the timeline
  • Errors are also being displayed in the timeline for easing debugging

For example, the request above is now displayed as following in the timeline: image

To limit the potentials lags induced by logging large requests payloads in case of errors, three new user preferences have been introduced : image

  • 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

Contribution Checklist:

  • [X] The pull request only addresses one issue or adds one feature.
  • [X] The pull request does not introduce any breaking changes
  • [X] I have added screenshots or gifs to help explain the change if applicable.
  • [X] I have read the contribution guidelines.
  • [X] Create an issue and link to the pull request.

fredjeck avatar Feb 24 '24 22:02 fredjeck

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. If the request succeeded I think it would be nice to be able to display the scripting error in the response pane - however this would require deeper change. Therefore I would suggest this PR as a firststep which would avoid user frustration.

fredjeck avatar Feb 25 '24 10:02 fredjeck