-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[DataView] Fix multiple pattern matching #152552
Conversation
…-ref HEAD~1..HEAD --fix'
if (patternListActive.length === 0) { | ||
throw new DataViewMissingIndices(patternList.join(',')); | ||
} | ||
} |
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.
Since Matt is on PTO and also has been working on this issue, could you provide some context about this change, what is being fixed, and how it can be tested? Many thx!
BTW: some recent change in this area, to raise awareness #151788
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.
Hello, so the integration Test added by matt speaks for itself. when multiple heartbeat-8*,heartbeat-7*,synthetics-*
like this was provided and if none of them contained any index, request was matching to all the indices.
src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Matthias Wilhelm <[email protected]>
…-ref HEAD~1..HEAD --fix'
await supertest | ||
.get('/api/index_patterns/_fields_for_wildcard') | ||
.query({ pattern: 'bad_index,bad_index_2' }) | ||
.expect(404); |
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.
i think you will need to update test as well.
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.
@mattkime ^^
@@ -72,6 +72,9 @@ export class IndexPatternsFetcher { | |||
// if only one pattern, don't bother with validation. We let getFieldCapabilities fail if the single pattern is bad regardless | |||
if (patternList.length > 1 && !allowNoIndices) { | |||
patternListActive = await this.validatePatternListActive(patternList); | |||
if (patternListActive.length === 0) { | |||
return { fields: [], indices: [] }; |
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.
IMO we should back-port this as empty fields/indices list to 8.7 but in 8.8.0 we should throw error and communicate it to handle the error in UI.
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.
@shahzad31 we recently decided against that behavior since it can often result in 'toast storms' and does not align with the getting started experience.
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.
Got it. So i think in this case, if someone needs to really determine they can check length of indices to see if it actually matched any thing.
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.
@shahzad31 Yes, exactly, and handle it well for the user instead of depending upon the toast.
@shahzad31 does other work depend upon this PR? It seems that addressing tests will be more work than 'fixing' the code. |
if (indices.length === 0 && allowNoIndex !== true) { | ||
throw new DataViewMissingIndices(pattern); | ||
} |
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.
Why is this needed? shouldn't it just return an empty array of fields + indices in this case?
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.
@mattkime these changes should be removed, to make the PR green
This PR looks easier and removes unneeded code - #153350 |
await supertest | ||
.get('/api/index_patterns/_fields_for_wildcard') | ||
.query({ pattern: 'bad_index,bad_index_2' }) | ||
.expect(404); |
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.
.expect(404); | |
.expect(200); |
since it's no longer an error condition, this, with the reverting the change for fields_for
should make this PR ready to merge
Closing in favor of #153350 - will bring over the api integration test. |
💚 Build Succeeded
Metrics [docs]Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: |
Summary
If multiple patterns are provided and it matches no indices. it should return 404.
Example
heartbeat-8*,heartbeat-7*,synthetics-*