Skip to content

Commit

Permalink
Update dependency @elastic/elasticsearch to ^8.0.0-canary.17 (#107536)
Browse files Browse the repository at this point in the history
* Update dependency @elastic/elasticsearch to ^8.0.0-canary.15

* update tests for new error message building mechanism

* fix integration tests

* fix functional test

* mute new type errors

* fix new type errors

* bump es client to canaary.16

* fix integration test

* fix type errors in infra plugin

* mute type error in ml plugin

* fix type errors in monitoring plugin

* fix and mute errors in security solution plugin

* bump version to canary.18

* remove an unnecessary change

Co-authored-by: Renovate Bot <bot@renovateapp.com>
Co-authored-by: restrry <restrry@gmail.com>
  • Loading branch information
3 people committed Aug 17, 2021
1 parent b1f38f4 commit 41162c3
Show file tree
Hide file tree
Showing 22 changed files with 38 additions and 45 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"@elastic/apm-rum-react": "^1.2.11",
"@elastic/charts": "33.2.2",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.14",
"@elastic/elasticsearch": "npm:@elastic/elasticsearch-canary@^8.0.0-canary.17",
"@elastic/ems-client": "7.15.0",
"@elastic/eui": "37.1.1",
"@elastic/filesaver": "1.1.2",
Expand Down
7 changes: 4 additions & 3 deletions src/core/server/elasticsearch/client/configure_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const createApiResponse = <T>({
headers,
warnings,
meta: {
body,
request: {
params: params!,
options: requestOptions,
Expand Down Expand Up @@ -367,7 +368,7 @@ describe('configureClient', () => {
it('logs default error info when the error response body is empty', () => {
const client = configureClient(createFakeConfig(), { logger, type: 'test', scoped: false });

let response = createApiResponse({
let response: RequestEvent<any, any> = createApiResponse({
statusCode: 400,
headers: {},
params: {
Expand All @@ -384,7 +385,7 @@ describe('configureClient', () => {
Array [
Array [
"400
GET /_path [undefined]: Response Error",
GET /_path [undefined]: {\\"error\\":{}}",
undefined,
],
]
Expand All @@ -399,7 +400,7 @@ describe('configureClient', () => {
method: 'GET',
path: '/_path',
},
body: {} as any,
body: undefined,
});
client.emit('response', new errors.ResponseError(response), response);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,17 +421,13 @@ describe('migration actions', () => {
timeout: '0s',
})();

await cloneIndexPromise.then((res) => {
expect(res).toMatchInlineSnapshot(`
Object {
"_tag": "Left",
"left": Object {
"error": [ResponseError: Response Error],
"message": "Response Error",
"type": "retryable_es_client_error",
},
}
`);
await expect(cloneIndexPromise).resolves.toMatchObject({
_tag: 'Left',
left: {
error: expect.any(ResponseError),
message: expect.stringMatching(/\"timed_out\":true/),
type: 'retryable_es_client_error',
},
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('Elasticsearch Errors', () => {
{ ignore: [403] }
);

// @ts-expect-error @elastic/elasticsearch doesn't declare error on IndexResponse
expect(isWriteBlockException(res.body.error!)).toEqual(true);
});

Expand All @@ -79,6 +80,7 @@ describe('Elasticsearch Errors', () => {
{ ignore: [403] }
);

// @ts-expect-error @elastic/elasticsearch doesn't declare error on IndexResponse
expect(isWriteBlockException(res.body.error!)).toEqual(true);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('savedObjectsClient/decorateEsError', () => {
expect(SavedObjectsErrorHelpers.isGeneralError(error)).toBe(false);
const genericError = decorateEsError(error);
expect(genericError.message).toEqual(
`Saved object index alias [.kibana_8.0.0] not found: Response Error`
`Saved object index alias [.kibana_8.0.0] not found: {\"error\":{\"reason\":\"no such index [.kibana_8.0.0] and [require_alias] request flag is [true] and [.kibana_8.0.0] is not an alias\"}}`
);
expect(genericError.output.statusCode).toBe(500);
expect(SavedObjectsErrorHelpers.isGeneralError(error)).toBe(true);
Expand Down
1 change: 1 addition & 0 deletions src/core/server/saved_objects/service/lib/repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,7 @@ export class SavedObjectsRepository {
}

const deleteDocNotFound = body.result === 'not_found';
// @ts-expect-error @elastic/elasticsearch doesn't declare error on DeleteResponse
const deleteIndexNotFound = body.error && body.error.type === 'index_not_found_exception';
const esServerSupported = isSupportedEsServer(headers);
if (deleteDocNotFound || deleteIndexNotFound) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('handleEsError', () => {

expect(payload).toEqual({
attributes: { causes: undefined, error: undefined },
message: 'Response Error',
message: '{}',
});

expect(status).toBe(400);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export class ClusterClientAdapter<TDoc extends { body: AliasAny; index: string }
'kibana.saved_objects.id': ids,
},
},
// @ts-expect-error undefined is not assignable as QueryDslTermQuery value
namespaceQuery,
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { estypes } from '@elastic/elasticsearch';
import type { estypes } from '@elastic/elasticsearch';
import { i18n } from '@kbn/i18n';
import {
ALERT_EVALUATION_THRESHOLD,
Expand Down Expand Up @@ -650,13 +650,8 @@ export const getUngroupedESQuery = (
};
};

type SupportedESQueryTypes = 'term' | 'match' | 'match_phrase' | 'range';
type Filter = {
[key in SupportedESQueryTypes]?: object;
};

const buildFiltersForCriteria = (criteria: CountCriteria) => {
let filters: Filter[] = [];
let filters: estypes.QueryDslQueryContainer[] = [];

criteria.forEach((criterion) => {
const criterionQuery = buildCriterionQuery(criterion);
Expand All @@ -667,7 +662,7 @@ const buildFiltersForCriteria = (criteria: CountCriteria) => {
return filters;
};

const buildCriterionQuery = (criterion: Criterion): Filter | undefined => {
const buildCriterionQuery = (criterion: Criterion): estypes.QueryDslQueryContainer | undefined => {
const { field, value, comparator } = criterion;

const queryType = getQueryMappingForComparator(comparator);
Expand All @@ -691,7 +686,7 @@ const buildCriterionQuery = (criterion: Criterion): Filter | undefined => {
case 'match_phrase': {
return {
match_phrase: {
[field]: value,
[field]: String(value),
},
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const createLogEntryCategoryExamplesQuery = (
match: {
message: {
query: categoryQuery,
operator: 'AND',
operator: 'and',
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const createLogEntryExamplesQuery = (
match: {
message: {
query: categoryQuery,
operator: 'AND' as const,
operator: 'and' as const,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

import type { estypes } from '@elastic/elasticsearch';
import { isEmpty, isObject } from 'lodash/fp';
import type { Type } from '@kbn/securitysolution-io-ts-list-types';

export type QueryFilterType = [
{ term: Record<string, unknown> },
{ terms: Record<string, unknown[]> } | { bool: {} }
];
export type QueryFilterType = estypes.QueryDslQueryContainer[];

/**
* Given a type, value, and listId, this will return a valid query. If the type is
Expand Down Expand Up @@ -166,6 +163,7 @@ export const getShouldQuery = ({
{
bool: {
minimum_should_match: 1,
// @ts-expect-error unknown is not assignable to estypes.QueryDslQueryContainer
should,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@ export class JobCreator {
if (enable) {
this._job_config.results_index_name = this._job_config.job_id;
} else {
// @ts-expect-error The operand of a 'delete' operator must be optional
delete this._job_config.results_index_name;
}
}
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/monitoring/server/alerts/base_rule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export class BaseRule {
? {
timestamp: {
format: 'epoch_millis',
gte: +new Date() - limit - this.ruleOptions.fetchClustersRange,
gte: String(+new Date() - limit - this.ruleOptions.fetchClustersRange),
},
}
: undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { AlertCluster } from '../../../common/types/alerts';
interface RangeFilter {
[field: string]: {
format?: string;
gte: string | number;
gte: string;
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ describe('GET remote clusters', () => {
causes: undefined,
error: undefined,
},
message: 'Response Error',
message: '{"message":"test error"}',
});

expect(getSettingsMockFn).toHaveBeenCalled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export function handleEntities(): RequestHandler<unknown, TypeOf<typeof validate
{
// only return documents with the matching _id
ids: {
// @ts-expect-error expected string[]
values: _id,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ export const getSignalsIndicesInRange = async ({
'@timestamp': {
gte: from,
lte: 'now',
// @ts-expect-error format doesn't exist in RangeQuery
format: 'strict_date_optional_time',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ export const buildEventsSearchQuery = ({
'@timestamp': {
lte: to,
gte: from,
// @ts-expect-error
format: 'strict_date_optional_time',
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const buildIndicatorShouldClauses = (

if (!isEmpty(eventFieldValue)) {
shoulds.push({
// @ts-expect-error unknown is not assignable to query
match: {
[EVENT_ENRICHMENT_INDICATOR_FIELD_MAP[eventField]]: {
query: eventFieldValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export default function ({ getService }: FtrProviderContext) {
expect(body).to.eql({
statusCode: 404,
error: 'Not Found',
message: 'Response Error',
message: '{}',
attributes: {},
});
});
Expand Down Expand Up @@ -494,7 +494,7 @@ export default function ({ getService }: FtrProviderContext) {

expect(body).to.eql({
error: 'Not Found',
message: 'Response Error',
message: '{"_index":"test_index","_id":"2","found":false}',
statusCode: 404,
attributes: {},
});
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1433,10 +1433,10 @@
dependencies:
"@elastic/ecs-helpers" "^1.1.0"

"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.14":
version "8.0.0-canary.14"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.14.tgz#36f0dedc5e02c43a2fd1ceb86e273e29c603f1fb"
integrity sha512-ZwyjT16581grvJLgsbkT9tzy49g5E2qYQ05mS41Db98Kqe0sYZsm25eHGuV7U9DqJo5LuV0TTTs3rhsaqL5Mhw==
"@elastic/elasticsearch@npm:@elastic/elasticsearch-canary@^8.0.0-canary.17":
version "8.0.0-canary.17"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch-canary/-/elasticsearch-canary-8.0.0-canary.17.tgz#0625a04cc585e3f311bc6471e04cd4fb0e927e9a"
integrity sha512-rsbEdzxYlEU+jS+qf5Gr3+2U6/1Z/S/Yt2dM7lp1A64mCjuOqqHoR2FTHN27BWvBCjtJrtyhlCJht4fsTLNuYA==
dependencies:
debug "^4.3.1"
hpagent "^0.1.1"
Expand Down

0 comments on commit 41162c3

Please sign in to comment.