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

Fix invisible filters caused by missing index pattern #14131

Merged
merged 5 commits into from
Oct 3, 2017

Conversation

Bargs
Copy link
Contributor

@Bargs Bargs commented Sep 22, 2017

Fixes #7767
Replaces #13916

"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.

value = filter.meta.formattedValue;
} else {
value = filter.script.script.params.value;
value = field.format.convert(value);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else was pointless because map_phrase handles script filters that contain a params.value property (and appears before map_script in the mapping chain). I'm actually wondering if this map_script.js file is ever used. I dunno where meta.formattedValue would come from. Maybe @lukasolson has an idea?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think honestly when I added filter editors I updated the mapRange and mapPhrase functions to properly map scripted fields, so I think you're probably right... This might not ever get called.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spalger it looks like the formattedValue stuff was added in this PR. Any insights here? Not sure if it's safe to delete or if mapRange and mapPhrase should also be checking for a meta.formattedValue prop?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I really have no idea 😬

@Bargs
Copy link
Contributor Author

Bargs commented Sep 22, 2017

@stacey-gammon I thought you might be interested in reviewing since you filed an issue about this at one point.

Copy link
Contributor

@stacey-gammon stacey-gammon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor comments that I'll leave up to you, but lgtm.

: JSON.stringify(params.top_left);
const bottomRight = indexPattern
? indexPattern.fields.byName[key].format.convert(params.bottom_right)
: JSON.stringify(params.bottom_right);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be indented by two?

  const bottomRight = indexPattern
    ? indexPattern.fields.byName[key].format.convert(params.bottom_right)
    : JSON.stringify(params.bottom_right);

Same below, I think the .thens are supposed to be indented by two because it's a continuation of the original line.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the ternary expressions, but the thens are a separate matter. This style guide rule was changed at some point but the code base was never reformatted en masse. I'm following the existing style in these files in order to avoid having inconsistent styles within a single module.

const params = filter.geo_bounding_box[key];
const topLeft = field.format.convert(params.top_left);
const bottomRight = field.format.convert(params.bottom_right);
const topLeft = indexPattern
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment would be helpful:
indexPatterns are only used to find the field formatter for this field. An index pattern might not exist in some filters (... do you know how this can happen?), in which case we just display the raw value.

Up to you, but I found this code easy to read only after I read your comments on the PR, and a developer reading the code won't have that benefit.

Or maybe a comment for this getParams function at the top that says indexPattern is an optional parameter and used to format the field if given.

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of comments inline.

value = filter.meta.formattedValue;
} else {
value = filter.script.script.params.value;
value = field.format.convert(value);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think honestly when I added filter editors I updated the mapRange and mapPhrase functions to properly map scripted fields, so I think you're probably right... This might not ever get called.

if (error instanceof SavedObjectNotFound) {
return getParams();
}
throw error;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we gain by throwing the error here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I want the promise to reject in order to preserve the old behavior for errors that are not of type SavedObjectNotFound.

@Bargs
Copy link
Contributor Author

Bargs commented Sep 27, 2017

@lukasolson updated and ready for another look. I removed map_script since I couldn't see a path through which it would ever be reached.

@Bargs
Copy link
Contributor Author

Bargs commented Sep 29, 2017

jenkins, test this

@Bargs Bargs force-pushed the invisibleFiltersTake2 branch from 351fa03 to 32f54ef Compare October 2, 2017 18:18
@Bargs
Copy link
Contributor Author

Bargs commented Oct 2, 2017

These tests ran fine locally, let's see if a rebase fixes it in CI.

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Bargs Bargs merged commit 0fd8289 into elastic:master Oct 3, 2017
Bargs added a commit to Bargs/kibana that referenced this pull request Oct 3, 2017
"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.
Bargs added a commit that referenced this pull request Oct 3, 2017
"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.
Bargs added a commit to Bargs/kibana that referenced this pull request Oct 4, 2017
"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.
Bargs added a commit that referenced this pull request Oct 4, 2017
"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Oct 4, 2017
"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.
chrisronline added a commit to chrisronline/kibana that referenced this pull request Oct 4, 2017
chrisronline added a commit that referenced this pull request Oct 5, 2017
* Adds ability to change index pattern on import

Signed-off-by: Tyler Smalley <[email protected]>

* UI changes. Use a table in the modal grouped by index pattern id instead of multiple modals.

* PR feedback

* PR feedback

* PR updates

* Handle skip properly

* Fix error when there were no existing index patterns

* Tests for the new import conflict logic

* Fix invisible filters caused by missing index pattern (#14131)

"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.

* Show query and filter bars even when there's a linked search (#14212)

The query bar used to be hidden in the presence of a linked search because unlike filters, queries didn't get merged when flattening a SearchSource hierarchy. That means a query in the query bar would override the query in the linked search. This is no longer the case. As of 6.0 we include all queries in the SearchSource hierarchy in the final request, so there's no longer any reason to hide the query bar.

Since filters created via a Vis show up in the query bar when Kuery is selected, these filters now appear correctly even when there's a linked search in the vis editor.

Previously when unlinking a saved search visualize would insert the query and filters from the saved search into app state before removing the SearchSource from the hierarcy. This posed a problem because combining two lucene query strings isn't as easy as combing two sets of filters. We decided this behavior was a bit counterintuitive anyway. If the user wants to unlink the saved search, they probably want to discard it, not combine it with their local changes. So I've also updated the unlinking functionality to discard the saved search.

* limit wait time for baselayer (#14047)

* adding scope appy back (#14269)

* remove junk tests (#14191)

* We are using the index pattern id now

* Use the index pattern id here too

* Use an isolated es env for these tests

* Revert "Fix invisible filters caused by missing index pattern (#14131)"

This reverts commit e09d7ad.

* Revert "Show query and filter bars even when there's a linked search (#14212)"

This reverts commit 3aee7c2.

* Revert "limit wait time for baselayer (#14047)"

This reverts commit 44a7107.

* Revert "adding scope appy back (#14269)"

This reverts commit 51b6b51.

* Revert "remove junk tests (#14191)"

This reverts commit f06c183.

* Revert these
chrisronline added a commit to chrisronline/kibana that referenced this pull request Oct 5, 2017
* Adds ability to change index pattern on import

Signed-off-by: Tyler Smalley <[email protected]>

* UI changes. Use a table in the modal grouped by index pattern id instead of multiple modals.

* PR feedback

* PR feedback

* PR updates

* Handle skip properly

* Fix error when there were no existing index patterns

* Tests for the new import conflict logic

* Fix invisible filters caused by missing index pattern (elastic#14131)

"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.

* Show query and filter bars even when there's a linked search (elastic#14212)

The query bar used to be hidden in the presence of a linked search because unlike filters, queries didn't get merged when flattening a SearchSource hierarchy. That means a query in the query bar would override the query in the linked search. This is no longer the case. As of 6.0 we include all queries in the SearchSource hierarchy in the final request, so there's no longer any reason to hide the query bar.

Since filters created via a Vis show up in the query bar when Kuery is selected, these filters now appear correctly even when there's a linked search in the vis editor.

Previously when unlinking a saved search visualize would insert the query and filters from the saved search into app state before removing the SearchSource from the hierarcy. This posed a problem because combining two lucene query strings isn't as easy as combing two sets of filters. We decided this behavior was a bit counterintuitive anyway. If the user wants to unlink the saved search, they probably want to discard it, not combine it with their local changes. So I've also updated the unlinking functionality to discard the saved search.

* limit wait time for baselayer (elastic#14047)

* adding scope appy back (elastic#14269)

* remove junk tests (elastic#14191)

* We are using the index pattern id now

* Use the index pattern id here too

* Use an isolated es env for these tests

* Revert "Fix invisible filters caused by missing index pattern (elastic#14131)"

This reverts commit e09d7ad.

* Revert "Show query and filter bars even when there's a linked search (elastic#14212)"

This reverts commit 3aee7c2.

* Revert "limit wait time for baselayer (elastic#14047)"

This reverts commit 44a7107.

* Revert "adding scope appy back (elastic#14269)"

This reverts commit 51b6b51.

* Revert "remove junk tests (elastic#14191)"

This reverts commit f06c183.

* Revert these
chrisronline added a commit to chrisronline/kibana that referenced this pull request Oct 5, 2017
* Adds ability to change index pattern on import

Signed-off-by: Tyler Smalley <[email protected]>

* UI changes. Use a table in the modal grouped by index pattern id instead of multiple modals.

* PR feedback

* PR feedback

* PR updates

* Handle skip properly

* Fix error when there were no existing index patterns

* Tests for the new import conflict logic

* Fix invisible filters caused by missing index pattern (elastic#14131)

"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.

* Show query and filter bars even when there's a linked search (elastic#14212)

The query bar used to be hidden in the presence of a linked search because unlike filters, queries didn't get merged when flattening a SearchSource hierarchy. That means a query in the query bar would override the query in the linked search. This is no longer the case. As of 6.0 we include all queries in the SearchSource hierarchy in the final request, so there's no longer any reason to hide the query bar.

Since filters created via a Vis show up in the query bar when Kuery is selected, these filters now appear correctly even when there's a linked search in the vis editor.

Previously when unlinking a saved search visualize would insert the query and filters from the saved search into app state before removing the SearchSource from the hierarcy. This posed a problem because combining two lucene query strings isn't as easy as combing two sets of filters. We decided this behavior was a bit counterintuitive anyway. If the user wants to unlink the saved search, they probably want to discard it, not combine it with their local changes. So I've also updated the unlinking functionality to discard the saved search.

* limit wait time for baselayer (elastic#14047)

* adding scope appy back (elastic#14269)

* remove junk tests (elastic#14191)

* We are using the index pattern id now

* Use the index pattern id here too

* Use an isolated es env for these tests

* Revert "Fix invisible filters caused by missing index pattern (elastic#14131)"

This reverts commit e09d7ad.

* Revert "Show query and filter bars even when there's a linked search (elastic#14212)"

This reverts commit 3aee7c2.

* Revert "limit wait time for baselayer (elastic#14047)"

This reverts commit 44a7107.

* Revert "adding scope appy back (elastic#14269)"

This reverts commit 51b6b51.

* Revert "remove junk tests (elastic#14191)"

This reverts commit f06c183.

* Revert these
chrisronline added a commit to chrisronline/kibana that referenced this pull request Oct 5, 2017
* Adds ability to change index pattern on import

Signed-off-by: Tyler Smalley <[email protected]>

* UI changes. Use a table in the modal grouped by index pattern id instead of multiple modals.

* PR feedback

* PR feedback

* PR updates

* Handle skip properly

* Fix error when there were no existing index patterns

* Tests for the new import conflict logic

* Fix invisible filters caused by missing index pattern (elastic#14131)

"invisible filters" occur when the mapping chain throws an error. If a single filter throws an error, the entire chain rejects. As a result, not even the valid filters appear in the filter bar because they never get added to the scope. However the filters still exist in app state and still get sent with each search request.

The most common error occurs when the filter's meta.index property points to a non-existing index pattern. Since this property is only used for looking up field formatters and it is not essential for a working filter, we now fall back on raw values instead of failing if the index pattern is not found. See the PR this one replaces for discussion about other solutions we tried and why we chose to go this route.

* Show query and filter bars even when there's a linked search (elastic#14212)

The query bar used to be hidden in the presence of a linked search because unlike filters, queries didn't get merged when flattening a SearchSource hierarchy. That means a query in the query bar would override the query in the linked search. This is no longer the case. As of 6.0 we include all queries in the SearchSource hierarchy in the final request, so there's no longer any reason to hide the query bar.

Since filters created via a Vis show up in the query bar when Kuery is selected, these filters now appear correctly even when there's a linked search in the vis editor.

Previously when unlinking a saved search visualize would insert the query and filters from the saved search into app state before removing the SearchSource from the hierarcy. This posed a problem because combining two lucene query strings isn't as easy as combing two sets of filters. We decided this behavior was a bit counterintuitive anyway. If the user wants to unlink the saved search, they probably want to discard it, not combine it with their local changes. So I've also updated the unlinking functionality to discard the saved search.

* limit wait time for baselayer (elastic#14047)

* adding scope appy back (elastic#14269)

* remove junk tests (elastic#14191)

* We are using the index pattern id now

* Use the index pattern id here too

* Use an isolated es env for these tests

* Revert "Fix invisible filters caused by missing index pattern (elastic#14131)"

This reverts commit e09d7ad.

* Revert "Show query and filter bars even when there's a linked search (elastic#14212)"

This reverts commit 3aee7c2.

* Revert "limit wait time for baselayer (elastic#14047)"

This reverts commit 44a7107.

* Revert "adding scope appy back (elastic#14269)"

This reverts commit 51b6b51.

* Revert "remove junk tests (elastic#14191)"

This reverts commit f06c183.

* Revert these
@optical
Copy link

optical commented Nov 12, 2017

I may be misunderstanding the labels on this ticket, but I assume this fix only applies to Kibana 6.0? Got stung by #7767 while running Kibana 5.5. Just wondering if this is fixed in the lastest 5.X release, or if it will ever be?

@Bargs
Copy link
Contributor Author

Bargs commented Nov 13, 2017

@optical you're correct, this fix is only in 6.0+. It's unlikely we'll backport to 5.x. With 6.0 incoming we're only backporting fixes for high severity bugs at this point, to keep 5.x as stable as possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants