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

[Canvas] switch function skips case statements #110509

Closed
th0ger opened this issue Aug 30, 2021 · 3 comments
Closed

[Canvas] switch function skips case statements #110509

th0ger opened this issue Aug 30, 2021 · 3 comments
Labels
bug Fixes for quality problems that affect the customer experience Feature:Canvas Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas

Comments

@th0ger
Copy link

th0ger commented Aug 30, 2021

Kibana version: 7.14.0

Describe the bug:
The switch statement in Canvas is broken after upgrading to 7.14.0.
It seems that if the first case is not matched, the switch statement jumps over all other cases, and returns the default statement.

Steps to reproduce:

switch 
  {case if=false then="case1"}
  {case if=true then="case2"}
  default="default"
| render as=debug

returns
{ "text": "default" }

Expected behavior:
{ "text": "case2" }

Any additional context:

  • We upgraded from 7.13.3 which worked as expected.
  • Notice, if case 1 is true, it returns the expected value:
switch 
  {case if=true then="case1"}
  {case if=false then="case2"}
  default="default"
| render as=debug

returns { "text": "case1" }

  • I tried to prefice the case statement with case={...} which is optional according to the function reference. The result is the same.
@th0ger th0ger added the bug Fixes for quality problems that affect the customer experience label Aug 30, 2021
@botelastic botelastic bot added the needs-team Issues missing a team label label Aug 30, 2021
@th0ger
Copy link
Author

th0ger commented Sep 2, 2021

Anyone? This is a critical breaking change.

@vadimkibana vadimkibana added Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas and removed needs-team Issues missing a team label labels Sep 3, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-presentation (Team:Presentation)

@crob611
Copy link
Contributor

crob611 commented Sep 3, 2021

This is indeed a bug and not an intended breaking change. This is also duplicate of #107934

A fix has been applied and will be available in 7.14.1

In the meantime, to workaround this bug, you can switch to using nested if statements instead of the switch/case logic.

For example

if={compare op="eq" to=1} then="green" else={ if={compare op="eq" to=0} then="blue" else ={...etc}}

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:Canvas Team:Presentation Presentation Team for Dashboard, Input Controls, and Canvas
Projects
None yet
Development

No branches or pull requests

5 participants