[Discover][Main] Fix missing error message when building search query throws exceptions (#103923)

* Fix missing error message when building search fails

* Fix test

* Update _date_nested.ts

* Lint config.js

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Matthias Wilhelm 2021-07-14 12:18:21 +02:00 committed by GitHub
parent b2a6a9d308
commit 1fe4135ab6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 1 deletions

View file

@ -279,13 +279,21 @@ export const useSavedSearch = ({
).pipe(debounceTime(100));
const subscription = fetch$.subscribe((val) => {
fetchAll(val === 'reset');
try {
fetchAll(val === 'reset');
} catch (error) {
data$.next({
state: FetchStatus.ERROR,
fetchError: error,
});
}
});
return () => {
subscription.unsubscribe();
};
}, [
data$,
data.query.queryString,
filterManager,
refetch$,

View file

@ -0,0 +1,35 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import { FtrProviderContext } from '../../ftr_provider_context';
export default function ({ getService, getPageObjects }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const testSubjects = getService('testSubjects');
const PageObjects = getPageObjects(['common', 'timePicker', 'discover']);
const security = getService('security');
describe('timefield is a date in a nested field', function () {
before(async function () {
await esArchiver.loadIfNeeded('test/functional/fixtures/es_archiver/date_nested');
await security.testUser.setRoles(['kibana_admin', 'kibana_date_nested']);
await PageObjects.common.navigateToApp('discover');
});
after(async function unloadMakelogs() {
await security.testUser.restoreDefaults();
await esArchiver.unload('test/functional/fixtures/es_archiver/date_nested');
});
it('should show an error message', async function () {
await PageObjects.discover.selectIndexPattern('date-nested');
await PageObjects.discover.waitUntilSearchingHasFinished();
await testSubjects.existOrFail('discoverNoResultsError');
});
});
}

View file

@ -51,5 +51,6 @@ export default function ({ getService, loadTestFile }: FtrProviderContext) {
loadTestFile(require.resolve('./_indexpattern_with_unmapped_fields'));
loadTestFile(require.resolve('./_runtime_fields_editor'));
loadTestFile(require.resolve('./_huge_fields'));
loadTestFile(require.resolve('./_date_nested'));
});
}

View file

@ -247,6 +247,21 @@ export default async function ({ readConfigFile }) {
},
kibana: [],
},
kibana_date_nested: {
elasticsearch: {
cluster: [],
indices: [
{
names: ['date-nested'],
privileges: ['read', 'view_index_metadata'],
field_security: { grant: ['*'], except: [] },
},
],
run_as: [],
},
kibana: [],
},
kibana_message_with_newline: {
elasticsearch: {
cluster: [],

View file

@ -0,0 +1,30 @@
{
"type": "doc",
"value": {
"id": "index-pattern:date-nested",
"index": ".kibana",
"source": {
"index-pattern": {
"fields":"[]",
"timeFieldName": "@timestamp",
"title": "date-nested"
},
"type": "index-pattern"
}
}
}
{
"type": "doc",
"value": {
"id": "date-nested-1",
"index": "date-nested",
"source": {
"message" : "test",
"nested": {
"timestamp": "2021-06-30T12:00:00.123Z"
}
}
}
}

View file

@ -0,0 +1,22 @@
{
"type": "index",
"value": {
"index": "date-nested",
"mappings": {
"properties": {
"message": {
"type": "text"
},
"nested": {
"type": "nested"
}
}
},
"settings": {
"index": {
"number_of_replicas": "0",
"number_of_shards": "1"
}
}
}
}