elastic / kibana

Your window into the Elastic Stack
https://www.elastic.co/products/kibana
Other
19.62k stars 8.22k forks source link

[Console] Parser can't parse valid requests after an invalid one #193552

Open yuliacech opened 1 month ago

yuliacech commented 1 month ago

The parser (source file) is currently used to detect the start and the end of requests in Console with further processing of the requests done in MonacoEditorActionsProvider (source file).

If a request is invalid, the parser stops working and can't detect any requests that might be valid after the invalid one. That happens because if the parser sees any character that is unexpected, an error is thrown (see this line).

A possible fix for this would be to have some logic in the parser, that would catch the error, register it to be displayed in the Console for the user and then restart the parsing process. I think we already have that logic in the function multi_request (see this code):

catch (e) {
          addError(e.message);
          // snap
          const substring = text.substr(at);
          const nextMatch = substring.search(/^POST|HEAD|GET|PUT|DELETE|PATCH/m);
          if (nextMatch < 1) return;
          reset(at + nextMatch);
        }
elasticmachine commented 1 month ago

Pinging @elastic/kibana-management (Team:Kibana Management)