Controls vis - safely handle case where value can not be extracted from Kibana filter#22885
Controls vis - safely handle case where value can not be extracted from Kibana filter#22885nreese merged 2 commits intoelastic:masterfrom
Conversation
💚 Build Succeeded |
chrisdavies
left a comment
There was a problem hiding this comment.
LTGM w/ the tweaks I mentioned.
I pulled it down and tested in both master and this branch. Master reproduced the error, this branch did not. 🎉 🎂
| return this._getValueFromFilter(kbnFilter); | ||
| }) | ||
| .filter(value => { | ||
| if (typeof value === 'undefined' || value == null) { |
There was a problem hiding this comment.
The entire filter could become this: .filter(value => value != null), if you want to keep the != instead of !==. Alternatively, it could be: .filter(value => typeof value !== 'undefined' && value !== null).
| return true; | ||
| }); | ||
|
|
||
| if (values.length === 0) { |
There was a problem hiding this comment.
This if is unnecessary, as the filter will mean that reduce will be operating over an empty array in the test case, which should be just fie.
There was a problem hiding this comment.
If the filter removes all items from the array then reduce would return []. The function should return undefined if there are no selected options.
| } | ||
|
|
||
| return fromRange(range); | ||
| if (range == null) { |
There was a problem hiding this comment.
Just double-checking that you wanted a == instead of a ===. Might want to slap a comment in here, if you do, as this is usually frowned upon, but it is a handy way to check for null and undefined simultaneously.
💚 Build Succeeded |
…om Kibana filter (elastic#22885) * handle case where value can not be extracted from Kibana filter * review feedback
…om Kibana filter (elastic#22885) * handle case where value can not be extracted from Kibana filter * review feedback
|
Great can't wait to use the new version and test this out in my system that errors currently. I use Docker Kibana 6.4 currently and can pull a new version when this is ready. |
fixes #22607
The original error can be created with the following steps:
Options listcontrol. Set index-pattern and field.Apply changesso a filter pill is added to Kibana.fieldfor the options list control. When the new field is applied then the error will be shown.This resulted in passing
[{value: undefined, label: undefined}]toEuiComboBoxfor theselectedOptionsprops.This regression was introduced by PR #20002