Skip to content

Commit

Permalink
[Discover][Main] Fix missing error message when building search query…
Browse files Browse the repository at this point in the history
… 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>
  • Loading branch information
kertal and kibanamachine committed Jul 14, 2021
1 parent b2a6a9d commit 1fe4135
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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$,
Expand Down
35 changes: 35 additions & 0 deletions test/functional/apps/discover/_date_nested.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
}
1 change: 1 addition & 0 deletions test/functional/apps/discover/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
});
}
15 changes: 15 additions & 0 deletions test/functional/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down
30 changes: 30 additions & 0 deletions test/functional/fixtures/es_archiver/date_nested/data.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}
22 changes: 22 additions & 0 deletions test/functional/fixtures/es_archiver/date_nested/mappings.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
}
}

0 comments on commit 1fe4135

Please sign in to comment.