Skip to content
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

[Console] Triple quotes doesn't work for string longer than 2000 chars #136300

Closed
yuliacech opened this issue Jul 13, 2022 · 8 comments
Closed

[Console] Triple quotes doesn't work for string longer than 2000 chars #136300

yuliacech opened this issue Jul 13, 2022 · 8 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Console Dev Tools Console Feature Feature:Dev Tools Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more

Comments

@yuliacech
Copy link
Contributor

yuliacech commented Jul 13, 2022

Kibana version:
Current main branch be61682

Elasticsearch version:
Current es snapshot

Server OS version:
macOS Monterey 12.4

Browser version:
Google Chrome Version 103.0.5060.114 (Official Build) (x86_64)

Browser OS version:
macOS Monterey 12.4

Original install method (e.g. download page, yum, from source, etc.):
source code

Describe the bug:
It's not possible to use triple quotes in a Console request if the string is longer than 2000 characters. The bug only occurs if the string has no new lines.

Steps to reproduce:

  1. Navigate to Dev Tools Console
  2. Send following request:
PUT test/_doc/1
{
  "message": """Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla vehicula elit at velit scelerisque maximus. Nulla euismod massa ut arcu sodales facilisis. Nullam bibendum posuere tristique. Vestibulum sit amet lorem vitae erat elementum blandit et vitae magna. Vivamus tincidunt finibus rutrum. Donec vestibulum eleifend justo, id pharetra tellus laoreet vel. Donec lobortis quam sit amet ex accumsan molestie.Nunc pretium lectus sed eros lobortis scelerisque. Praesent gravida est metus, et dapibus erat condimentum id. Integer id mauris auctor, efficitur lacus ac, ultrices lorem. Ut ultricies nunc a dui suscipit semper. Nulla varius condimentum nunc sit amet suscipit. In magna tortor, molestie sed elit sit amet, porta porttitor turpis. Donec eros tortor, gravida ut auctor elementum, vulputate maximus lacus.Nunc in pretium urna, et fringilla ex. Ut eu massa a odio consectetur laoreet nec eu est. Integer at nisi est. Sed ac massa a libero egestas vestibulum. Suspendisse gravida augue mauris, eget rhoncus purus mollis at. Sed porttitor libero nibh, vel aliquet mauris hendrerit aliquet. Vestibulum accumsan turpis sit amet lectus sagittis, vel rhoncus ipsum aliquam. Nulla sed elementum enim. Cras id consequat sapien. Integer ornare bibendum risus. Pellentesque ipsum sapien, tempus non gravida nec, feugiat consectetur orci. Mauris viverra tortor eros, quis accumsan ligula varius at. Duis a nisi ac ex maximus blandit vitae at neque. Donec molestie urna nibh. Phasellus feugiat erat in tincidunt posuere.Aliquam eu nulla id arcu dapibus pulvinar. Phasellus ullamcorper, turpis a lacinia dictum, turpis arcu maximus magna, a luctus lorem nunc nec nisl. Phasellus iaculis placerat tellus, ac porta nibh maximus et. Proin ullamcorper luctus elit a congue. Nunc feugiat nunc in neque porttitor lobortis. Praesent ut tristique metus. Quisque vulputate porta mattis. Duis dapibus felis non euismod blandit.Pellentesque tristique tincidunt magna vel semper. Donec consectetur, lectus non eleifend sollicitudin,"""
}
  1. Highlighting for the end of the long triple-quoted string will be broken and the request will fail with a 400.

NOTE: If you insert a line break by hitting Enter in the middle of the long string, the highlighting works again as expected and the request will complete successfully.

{
  "statusCode": 400,
  "error": "Bad Request",
  "message": """[request query.method]: Method must be one of, case insensitive ['HEAD', 'GET', 'POST', 'PUT', 'DELETE']. Received '"message"'."""
}

image

Workaround:
If the triple quotes are replaced with single quotes, the request works even if the string length is extended.

Expected behavior:
The request should work as expected.

Screenshots (if relevant):

Errors in browser console (if relevant):

{"statusCode":400,"error":"Bad Request","message":"[request query.method]: Method must be one of, case insensitive ['HEAD', 'GET', 'POST', 'PUT', 'DELETE']. Received '\"message\"'."}

Provide logs and/or server output (if relevant):

Any additional context:

@yuliacech yuliacech added bug Fixes for quality problems that affect the customer experience Feature:Console Dev Tools Console Feature Feature:Dev Tools Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Jul 13, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/platform-deployment-management (Team:Deployment Management)

@yuliacech
Copy link
Contributor Author

The bug seems to have been there for a very long time, I could reproduce it in v7.0.1

@zishiguo
Copy link

@yuliacech Did you solve it?

@zishiguo
Copy link

I also met this question, v7.10.2

@alisonelizabeth
Copy link
Contributor

Hi @zishiguo this is still an open issue.

@sabarasaba
Copy link
Member

After some research I found that the tokenizer for multi-line request fails with an overflow error when attemting to find the end_triple_quote token. I'm trying to figure out how this works so I can issue a patch

Screenshot 2023-06-06 at 14 29 25

@sabarasaba
Copy link
Member

The text editor used for console is still based on the Ace text editor, this editor has a hardcoded limit for tokenizing lines and its capped at 2000 characters because otherwise will make the browser too slow.

This constraint makes the syntax highlighting fail (will be capped at 2000 characters) and the query delimiters fail too which means that when we select the query with a very long text the "send request" button will be placed on the body of the query instead of the query method and the query body:

Screenshot 2023-06-07 at 11 22 50

As a workaround for now, you can click on the query method instead of the body to correctly highlight the full query:

Screenshot 2023-06-07 at 11 25 03

We have plans of moving the editor to Monaco at some point which will solve this issue (and many others!) but for now I dont think we will be able to fix this.

@alisonelizabeth
Copy link
Contributor

Thanks for the investigation @sabarasaba!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Console Dev Tools Console Feature Feature:Dev Tools Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

No branches or pull requests

5 participants