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

[Bug] unexpected behavior from Canvas expression switch function #131657

Closed
drewdaemon opened this issue May 5, 2022 · 2 comments · Fixed by #139898
Closed

[Bug] unexpected behavior from Canvas expression switch function #131657

drewdaemon opened this issue May 5, 2022 · 2 comments · Fixed by #139898
Labels
bug Fixes for quality problems that affect the customer experience Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:small Small Level of Effort

Comments

@drewdaemon
Copy link
Contributor

Kibana version:
As far back as 7.17.1

Describe the bug:
The Canvas switch expression function evaluates all cases before selecting its final result. This seems like unexpected behavior and prevents a previous case from being used as a guard for a following case.

Steps to reproduce:

  1. Add kibana_sample_data_flights
  2. Go to new Canvas workpad
  3. Add shape -> edit expression
  4. Paste in the following
essql query="SELECT * FROM kibana_sample_data_flights LIMIT 0"
| shape "hexagon" fill={
  switch 
    {case if={rowCount | lt 1} then="grey"} 
    {case if={getCell "Carrier" | eq "Kibana Airlines"} then="green"} 
    default="red"
  }
| render containerStyle={containerStyle}
  1. click "Run"

Result: The second case (which invokes getCell) is evaluated even though the first case (which checks for an empty datatable) evaluates to true. This results in a runtime error from getCell being run on an empty table.
Screen Shot 2022-05-05 at 1 25 05 PM

The user can still guard their second case with an extra if function in a subexpression.

Expected behavior:
The switch function checks the cases serially. As soon as a case evaluates to true, the switch function resolves with that result.

@drewdaemon drewdaemon added bug Fixes for quality problems that affect the customer experience Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:AppServicesSv labels May 5, 2022
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesSv)

@exalate-issue-sync exalate-issue-sync bot added the impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. label Jul 21, 2022
@exalate-issue-sync exalate-issue-sync bot added impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. and removed impact:needs-assessment Product and/or Engineering needs to evaluate the impact of the change. labels Aug 9, 2022
@exalate-issue-sync exalate-issue-sync bot added the loe:small Small Level of Effort label Aug 26, 2022
@dokmic
Copy link
Contributor

dokmic commented Sep 1, 2022

Caused by #100409.

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:ExpressionLanguage Interpreter expression language (aka canvas pipeline) impact:medium Addressing this issue will have a medium level of impact on the quality/strength of our product. loe:small Small Level of Effort
Projects
None yet
3 participants