-
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
Changes from all commits
bcb9f8c
b246027
66ee68a
3fad229
8665168
ce77cfe
7c67413
4fdaec1
3ba5abb
94b301c
9691763
5ffe582
00227b4
35299c2
c98dc74
0abb1c5
d6aa974
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ import { | |
} from '@kbn/core/server'; | ||
import { IndexPatternsFetcher } from '../fetcher'; | ||
import type { DataViewsServerPluginStart, DataViewsServerPluginStartDependencies } from '../types'; | ||
import { DataViewMissingIndices } from '../../common'; | ||
|
||
const parseMetaFields = (metaFields: string | string[]) => { | ||
let parsedFields: string[] = []; | ||
|
@@ -91,6 +92,10 @@ const handler: RequestHandler<{}, IQuery, IBody> = async (context, request, resp | |
fields: request.query.fields, | ||
}); | ||
|
||
if (indices.length === 0 && allowNoIndex !== true) { | ||
throw new DataViewMissingIndices(pattern); | ||
} | ||
Comment on lines
+95
to
+97
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. @mattkime these changes should be removed, to make the PR green |
||
|
||
return response.ok({ | ||
body: { fields, indices }, | ||
headers: { | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -201,6 +201,14 @@ export default function ({ getService }) { | |||||
indices: ['basic_index'], | ||||||
}); | ||||||
}); | ||||||
|
||||||
it('returns 404 when neither exists', async () => { | ||||||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. @mattkime ^^ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
since it's no longer an error condition, this, with the reverting the change for |
||||||
}); | ||||||
|
||||||
it('returns 404 when no patterns exist', async () => { | ||||||
await supertest | ||||||
.get('/api/index_patterns/_fields_for_wildcard') | ||||||
|
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.