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

Dev Tools Console 8.x javascript error when sense:folds contains non-empty array with sense:console_local_text-object with non-empty string #151563

Closed
jguay opened this issue Feb 17, 2023 · 2 comments · Fixed by #152366
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Console Dev Tools Console Feature Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more

Comments

@jguay
Copy link
Contributor

jguay commented Feb 17, 2023

Kibana version:
8.6.1 (not reproduced in 7.17.8, also reproduced in 8.5.2)
Browser version:
Chrome Version 110.0.5481.100 (Official Build) (arm64)
Browser OS version:
MacOS 13.2.1 (22D68)
Original install method (e.g. download page, yum, from source, etc.):
docker
Describe the bug:
Not huge issue as clearing cache will solve but raising for reference as I got reproduction steps, Dev Tools Console does not load :
Screenshot 2023-02-17 at 10 20 27

Javascript error :

kbn-ui-shared-deps-npm.dll.js:398 Error: The range has to be at least 2 characters width
    at h.addFold (kbn-ui-shared-deps-npm.dll.js:350:703321)
    at console.chunk.1.js:12:197915
    at Array.forEach (<anonymous>)
    at legacy_core_editor_LegacyCoreEditor.addFoldsAtRanges (console.chunk.1.js:12:197900)
    at console.chunk.1.js:12:270381
    at console.chunk.1.js:12:270402
    at qu (kbn-ui-shared-deps-npm.dll.js:398:106314)
    at t.unstable_runWithPriority (kbn-ui-shared-deps-npm.dll.js:406:3768)
    at $i (kbn-ui-shared-deps-npm.dll.js:398:44909)
    at Uu (kbn-ui-shared-deps-npm.dll.js:398:105759)
Uncaught Error: The range has to be at least 2 characters width
    at h.addFold (kbn-ui-shared-deps-npm.dll.js:350:703321)
    at console.chunk.1.js:12:197915
    at Array.forEach (<anonymous>)
    at legacy_core_editor_LegacyCoreEditor.addFoldsAtRanges (console.chunk.1.js:12:197900)
    at console.chunk.1.js:12:270381
    at console.chunk.1.js:12:270402
    at qu (kbn-ui-shared-deps-npm.dll.js:398:106314)
    at t.unstable_runWithPriority (kbn-ui-shared-deps-npm.dll.js:406:3768)
    at $i (kbn-ui-shared-deps-npm.dll.js:398:44909)
    at Uu (kbn-ui-shared-deps-npm.dll.js:398:105759)
addFold @ kbn-ui-shared-deps-npm.dll.js:350
(anonymous) @ console.chunk.1.js:12
addFoldsAtRanges @ console.chunk.1.js:12
(anonymous) @ console.chunk.1.js:12
(anonymous) @ console.chunk.1.js:12
qu @ kbn-ui-shared-deps-npm.dll.js:398
t.unstable_runWithPriority @ kbn-ui-shared-deps-npm.dll.js:406
$i @ kbn-ui-shared-deps-npm.dll.js:398
Uu @ kbn-ui-shared-deps-npm.dll.js:398
Re @ kbn-ui-shared-deps-npm.dll.js:398
Zt @ kbn-ui-shared-deps-npm.dll.js:398

Steps to reproduce:

  1. Open Kibana Dev Tools and browse to Profiler
  2. Open browser developer tools -> Application -> Local Storage -> <kibana_url> (in my case https://localhost:5601 which I use for various versions of Kibana)
  3. Filter for sense: and delete all the keys found (or just delete key sense:console_local_text-object_*)
  4. Add the following 2 key/values
sense:folds	[{"start":{"row":1,"column":1},"end":{"row":82,"column":4}}]
sense:console_local_text-object_e69f508c-3342-45cf-ae7c-2753548ce8e7	{"id":"e69f508c-3342-45cf-ae7c-2753548ce8e7","createdAt":1675332935410,"updatedAt":1676630754720,"text":"GET _cat/indices"}
  1. Navigate in Kibana to Dev Tools Console now to reproduce

Note either the following will work around the issue :

  • change sense:folds to value []
  • change sense:console_local_text-object_e69f508c-3342-45cf-ae7c-2753548ce8e7 to empty text like {"id":"e69f508c-3342-45cf-ae7c-2753548ce8e7","createdAt":1675332935410,"updatedAt":1676630754720,"text":""}

Expected behavior:
No javascript stack trace

Any additional context:
In my case https://localhost:5601 is what I use for using short-lived kibana test systems on many versions, I had first issue on that and few weeks later on https://127.0.0.1 which I started using.
I did not check what sense:folds is holding but in 8.6.1, when I run any command in Dev Tools Console, this gets reset to an empty array... It looks like having a non-empty array for this and any non-empty string in field text for sense:console_local_text-object_<GUID> causes javascript error

@jguay jguay added bug Fixes for quality problems that affect the customer experience Feature:Console Dev Tools Console Feature labels Feb 17, 2023
@botelastic botelastic bot added the needs-team Issues missing a team label label Feb 17, 2023
@jguay jguay changed the title Dev Tools Console 8.x javascript error when sense:folds contains array Dev Tools Console 8.x javascript error when sense:folds contains non-empty array with sense:console_local_text-object with non-empty string Feb 17, 2023
@jughosta jughosta added the Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more label Feb 20, 2023
@elasticmachine
Copy link
Contributor

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

@botelastic botelastic bot removed the needs-team Issues missing a team label label Feb 20, 2023
@111andre111
Copy link

111andre111 commented Feb 24, 2023

Interesting, I have that issue now as well in one of my deployments.

I did a deeper analysis:

I right now compared with a completely other instance the values.
I had in console that error:
Unexpected token '@', "@@SENSE_REVISION" is not valid JSON
And it turned out that my problem was that the working one had in local storage following key-value: sense:version_welcome_shown="@@SENSE_REVISION" however my non-working instance had this one sense:version_welcome_shown=@@SENSE_REVISION.
See the missing quotes. After simply adding the quotes there it's now working again.

no clue how that could happen, but after correcting it's working now...

Maybe that helps a bit.

@yuliacech yuliacech self-assigned this Feb 24, 2023
yuliacech added a commit that referenced this issue Mar 6, 2023
## Summary
Fixes #151563 

There is a combination of the folds in the editor (collapsed lines) and
the text that can cause the editor to fail. This PR adds a try/catch
clause to the editor, so that the UI can still be used.


### How to use
1. Open Kibana and in your browser's Dev Tools, delete everything from
local storage.
2. Add following 2 items back to the local storage: 
```
sense:folds	[{"start":{"row":1,"column":1},"end":{"row":82,"column":4}}]
sense:console_local_text-object_e69f508c-3342-45cf-ae7c-2753548ce8e7	{"id":"e69f508c-3342-45cf-ae7c-2753548ce8e7","createdAt":1675332935410,"updatedAt":1676630754720,"text":"GET _cat/indices"} 
```
3. Navigate to Console in Kibana, make sure the editor works. 


### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
bmorelli25 pushed a commit to bmorelli25/kibana that referenced this issue Mar 10, 2023
## Summary
Fixes elastic#151563 

There is a combination of the folds in the editor (collapsed lines) and
the text that can cause the editor to fail. This PR adds a try/catch
clause to the editor, so that the UI can still be used.


### How to use
1. Open Kibana and in your browser's Dev Tools, delete everything from
local storage.
2. Add following 2 items back to the local storage: 
```
sense:folds	[{"start":{"row":1,"column":1},"end":{"row":82,"column":4}}]
sense:console_local_text-object_e69f508c-3342-45cf-ae7c-2753548ce8e7	{"id":"e69f508c-3342-45cf-ae7c-2753548ce8e7","createdAt":1675332935410,"updatedAt":1676630754720,"text":"GET _cat/indices"} 
```
3. Navigate to Console in Kibana, make sure the editor works. 


### Checklist

- [x] Any text added follows [EUI's writing
guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses
sentence case text and includes [i18n
support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md)
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 Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants