-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Controls vis - safely handle case where value can not be extracted from Kibana filter #22885
Conversation
💚 Build Succeeded |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. 🎉 🎂
.map((kbnFilter) => { | ||
return this._getValueFromFilter(kbnFilter); | ||
}) | ||
.filter(value => { | ||
if (typeof value === 'undefined' || value == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the filter removes all items from the array then reduce would return []
. The function should return undefined if there are no selected options.
@@ -76,7 +76,10 @@ export class RangeFilterManager extends FilterManager { | |||
range = _.get(kbnFilters[0], ['range', this.fieldName]); | |||
} | |||
|
|||
return fromRange(range); | |||
if (range == null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 list
control. Set index-pattern and field.Apply changes
so a filter pill is added to Kibana.field
for the options list control. When the new field is applied then the error will be shown.This resulted in passing
[{value: undefined, label: undefined}]
toEuiComboBox
for theselectedOptions
props.This regression was introduced by PR #20002