elastic / kibana

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

[Console] Line break is sometimes opaquely inserted when submitting request #193241

Open dgieselaar opened 2 months ago

dgieselaar commented 2 months ago

In some cases, when submitting a request with a certain pattern, console inserts a line break under the water which breaks the request, without a hint to the user as to why that has happened. Here's a snippet to reproduce:

PUT _ingest/pipeline/entities-v1-latest-builtin_data_streams
{
  "processors": [
    {
      "set": {
        "field": "entity.displayName",
        "value": "{{remote}}{{data_stream.type}}-{{data_stream.dataset}}-{{data_stream.namespace}}"
      }
    }
  ]
}

The issue is with {{remote}}{{data_stream.type}}. If that is changed to {{remote}}-{{data_stream.type}}, the request works again.

elasticmachine commented 2 months ago

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

yuliacech commented 2 months ago

This is a bug in the helper function splitDataIntoJsonObjects in this file. The function is used to detect when there are several json objects in the Console editor, for example for bulk requests. I think we could update the regex to not allow no whitespaces between the curly braces. It would make sense to maybe even force a new line between the braces:

// old regex 
const jsonSplitRegex = /}\s*{/;
// new regex alternative 1
const jsonSplitRegex = /}\s+{/;
// new regex alternative 2
const jsonSplitRegex = /}\n{/;
dryruffian commented 1 month ago

HI @yuliacech , @alisonelizabeth and @dgieselaar, Changing the regex to /}\s+{/ requires at least one whitespace character between the braces, which should solve the immediate issue while still allowing for various whitespace formatting (spaces, tabs, newlines). If this is a valid solution, can you assign this issue to me?

alisonelizabeth commented 1 month ago

Hi @dryruffian we have not investigated the issue yet, but if you'd like to work on it, please assign yourself and open a PR. We will gladly review and provide feedback. Thanks!

dryruffian commented 1 month ago

ok will doo thanks @alisonelizabeth