Skip to content

Commit

Permalink
Update dependency @elastic/elasticsearch to ^8.15.1 (main) (elastic#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
elastic-renovate-prod[bot] authored and tkajtoch committed Nov 12, 2024
1 parent 32f44b4 commit f1e8ca8
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 46 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
"@elastic/datemath": "5.0.3",
"@elastic/ebt": "^1.1.1",
"@elastic/ecs": "^8.11.1",
"@elastic/elasticsearch": "^8.15.0",
"@elastic/elasticsearch": "^8.15.1",
"@elastic/ems-client": "8.5.3",
"@elastic/eui": "97.3.0",
"@elastic/filesaver": "1.1.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,25 @@ describe('catchRetryableEsClientErrors', () => {
type: 'retryable_es_client_error',
});
});
it('ResponseError with retryable status code', async () => {
const statusCodes = [503, 401, 403, 408, 410, 429];
return Promise.all(
statusCodes.map(async (status) => {
const error = new esErrors.ResponseError(
elasticsearchClientMock.createApiResponse({
statusCode: status,
body: { error: { type: 'reason' } },
})
);
expect(
((await Promise.reject(error).catch(catchRetryableEsClientErrors)) as any).left
).toMatchObject({
message: 'reason',
type: 'retryable_es_client_error',
});
})
);
});
it.each([503, 401, 403, 408, 410, 429])(
'ResponseError with retryable status code (%d)',
async (status) => {
const error = new esErrors.ResponseError(
elasticsearchClientMock.createApiResponse({
statusCode: status,
body: { error: { type: 'reason' } },
})
);
expect(
((await Promise.reject(error).catch(catchRetryableEsClientErrors)) as any).left
).toMatchObject({
message:
status === 410
? 'This API is unavailable in the version of Elasticsearch you are using.'
: 'reason',
type: 'retryable_es_client_error',
});
}
);
});
});
1 change: 0 additions & 1 deletion packages/kbn-apm-synthtrace/src/lib/shared/base_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ export class SynthtraceEsClient<TFields extends Fields> {
await this.client.indices.resolveIndex({
name: this.indices.join(','),
expand_wildcards: ['open', 'hidden'],
// @ts-expect-error ignore_unavailable is not in the type definition, but it is accepted by es
ignore_unavailable: true,
})
).indices.map((index: { name: string }) => index.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const waitUntilDeployed = async ({
model_id: modelId,
});
const deploymentStats = statsRes.trained_model_stats[0]?.deployment_stats;
// @ts-expect-error deploymentStats.nodes not defined as array even if it is.
if (!deploymentStats || deploymentStats.nodes.length === 0) {
await sleep(delay);
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const createRandomSamplerWrapper = (options: RandomSamplerOptions) => {

return {
[aggName]: {
// @ts-expect-error `random_sampler` is not yet part of `AggregationsAggregationContainer`
random_sampler: {
probability,
...(options.seed ? { seed: options.seed } : {}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const transformElasticNamedSearchToListItem = ({
}: TransformElasticMSearchToListItemOptions): SearchListItemArraySchema => {
return value.map((singleValue, index) => {
const matchingHits = response.hits.hits.filter((hit) => {
if (hit.matched_queries != null) {
if (hit.matched_queries != null && Array.isArray(hit.matched_queries)) {
return hit.matched_queries.some((matchedQuery) => {
const [matchedQueryIndex] = matchedQuery.split('.');
return matchedQueryIndex === `${index}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ export const ExpandedRow: FC<ExpandedRowProps> = ({ item }) => {
key: `${perDeploymentStat.deployment_id}_${nodeName}`,
...perDeploymentStat,
...modelSizeStats,
// @ts-expect-error `throughput_last_minute` is not declared in ES Types
node: {
...pick(n, [
'average_inference_time_ms',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ export class MemoryUsageService {

const mlNodes = Object.entries(response.nodes).filter(([, node]) => node.roles.includes('ml'));

// @ts-expect-error `throughput_last_minute` is not declared in ES Types
const nodeDeploymentStatsResponses: NodeDeploymentStatsResponse[] = mlNodes.map(
([nodeId, node]) => {
const nodeFields = pick(node, NODE_FIELDS) as RequiredNodeFields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ export const groupAndMergeSignalMatches = (signalHits: SignalSourceHit[]): Signa
if (existingSignalHit == null) {
acc[signalId] = signalHit;
} else {
const existingQueries = existingSignalHit?.matched_queries ?? [];
const newQueries = signalHit.matched_queries ?? [];
const existingQueries = Array.isArray(existingSignalHit?.matched_queries)
? existingSignalHit.matched_queries
: [];
const newQueries = Array.isArray(signalHit.matched_queries) ? signalHit.matched_queries : [];
existingSignalHit.matched_queries = [...existingQueries, ...newQueries];

acc[signalId] = existingSignalHit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export async function getSignalsQueryMapFromThreatIndex(

while (maxThreatsReachedMap.size < eventsCount && threatList?.hits.hits.length > 0) {
threatList.hits.hits.forEach((threatHit) => {
const matchedQueries = threatHit?.matched_queries || [];
const matchedQueries = Array.isArray(threatHit?.matched_queries)
? threatHit.matched_queries
: [];

matchedQueries.forEach((matchedQuery) => {
const decodedQuery = decodeThreatMatchNamedQuery(matchedQuery);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ export const decodeThreatMatchNamedQuery = (encoded: string): DecodedThreatNamed
export const extractNamedQueries = (
hit: SignalSourceHit | ThreatListItem
): DecodedThreatNamedQuery[] =>
hit.matched_queries?.map((match) => decodeThreatMatchNamedQuery(match)) ?? [];
Array.isArray(hit.matched_queries)
? hit.matched_queries.map((match) => decodeThreatMatchNamedQuery(match))
: [];

export const buildExecutionIntervalValidator: (interval: string) => () => void = (interval) => {
const intervalDuration = parseInterval(interval);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ export const buildIndicatorShouldClauses = (
export const buildIndicatorEnrichments = (hits: estypes.SearchHit[]): CtiEnrichment[] => {
return hits.flatMap<CtiEnrichment>(({ matched_queries: matchedQueries, ...hit }) => {
return (
matchedQueries?.reduce<CtiEnrichment[]>((enrichments, matchedQuery) => {
if (isValidEventField(matchedQuery)) {
enrichments.push({
...hit.fields,
...buildIndicatorMatchedFields(hit, matchedQuery),
});
}
(Array.isArray(matchedQueries) ? matchedQueries : [])?.reduce<CtiEnrichment[]>(
(enrichments, matchedQuery) => {
if (isValidEventField(matchedQuery)) {
enrichments.push({
...hit.fields,
...buildIndicatorMatchedFields(hit, matchedQuery),
});
}

return enrichments;
}, []) ?? []
return enrichments;
},
[]
) ?? []
);
});
};
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1721,12 +1721,12 @@
"@elastic/transport" "^8.3.1"
tslib "^2.4.0"

"@elastic/elasticsearch@^8.15.0":
version "8.15.0"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch/-/elasticsearch-8.15.0.tgz#cb29b3ae33203c545d435cf3dc4b557c8b4961d5"
integrity sha512-mG90EMdTDoT6GFSdqpUAhWK9LGuiJo6tOWqs0Usd/t15mPQDj7ZqHXfCBqNkASZpwPZpbAYVjd57S6nbUBINCg==
"@elastic/elasticsearch@^8.15.1":
version "8.15.1"
resolved "https://registry.yarnpkg.com/@elastic/elasticsearch/-/elasticsearch-8.15.1.tgz#ca294ba11ed1514bf87d4a2e253b11f6cefd8552"
integrity sha512-L3YzSaxrasMMGtcxnktiUDjS5f177L0zpHsBH+jL0LgPhdMk9xN/VKrAaYzvri86IlV5IbveA0ANV6o/BDUmhQ==
dependencies:
"@elastic/transport" "^8.7.0"
"@elastic/transport" "^8.8.1"
tslib "^2.4.0"

"@elastic/[email protected]":
Expand Down Expand Up @@ -1906,10 +1906,10 @@
undici "^5.28.3"
yaml "^2.2.2"

"@elastic/transport@^8.3.1", "@elastic/transport@^8.7.0":
version "8.7.0"
resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-8.7.0.tgz#006987fc5583f61c266e0b1003371e82efc7a6b5"
integrity sha512-IqXT7a8DZPJtqP2qmX1I2QKmxYyN27kvSW4g6pInESE1SuGwZDp2FxHJ6W2kwmYOJwQdAt+2aWwzXO5jHo9l4A==
"@elastic/transport@^8.3.1", "@elastic/transport@^8.8.1":
version "8.8.1"
resolved "https://registry.yarnpkg.com/@elastic/transport/-/transport-8.8.1.tgz#d64244907bccdad5626c860b492faeef12194b1f"
integrity sha512-4RQIiChwNIx3B0O+2JdmTq/Qobj6+1g2RQnSv1gt4V2SVfAYjGwOKu0ZMKEHQOXYNG6+j/Chero2G9k3/wXLEw==
dependencies:
"@opentelemetry/api" "1.x"
debug "^4.3.4"
Expand Down

0 comments on commit f1e8ca8

Please sign in to comment.