From a6740118bd1aa2587cebb37fbae94565d5abc257 Mon Sep 17 00:00:00 2001 From: Gerard Soldevila Date: Thu, 18 Dec 2025 11:37:23 +0100 Subject: [PATCH 1/2] Ignore the reason and retry systematically --- .../catch_retryable_es_client_errors.test.ts | 43 ------------------- .../catch_retryable_es_client_errors.ts | 12 +----- .../wait_for_pickup_updated_mappings_task.ts | 5 +-- 3 files changed, 2 insertions(+), 58 deletions(-) diff --git a/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.test.ts b/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.test.ts index 5621a94e059bb..02e193fbf51d0 100644 --- a/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.test.ts +++ b/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.test.ts @@ -115,47 +115,4 @@ describe('catchRetryableSearchPhaseExecutionException', () => { } `); }); - it('retries search phase execution exception for "all shards failed"', async () => { - const error = new esErrors.ResponseError( - elasticsearchClientMock.createApiResponse({ - body: { - error: { - type: 'search_phase_execution_exception', - caused_by: { - type: 'search_phase_execution_exception', - reason: 'all shards failed', - }, - }, - }, - }) - ); - expect( - ((await Promise.reject(error).catch(catchRetryableSearchPhaseExecutionException)) as any).left - ).toMatchInlineSnapshot(` - Object { - "error": [ResponseError: search_phase_execution_exception - Caused by: - search_phase_execution_exception: all shards failed], - "message": "search_phase_execution_exception - Caused by: - search_phase_execution_exception: all shards failed", - "type": "retryable_es_client_error", - } - `); - }); - it('does not retry other errors', async () => { - const error = new esErrors.ResponseError( - elasticsearchClientMock.createApiResponse({ - body: { - error: { - type: 'search_phase_execution_exception', - reason: 'Malformed search query.', - }, - }, - }) - ); - await expect( - Promise.reject(error).catch(catchRetryableSearchPhaseExecutionException) - ).rejects.toBe(error); - }); }); diff --git a/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.ts b/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.ts index ae991b511d90c..af8fb8dbdc823 100644 --- a/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.ts +++ b/src/core/packages/saved-objects/migration-server-internal/src/actions/catch_retryable_es_client_errors.ts @@ -30,11 +30,6 @@ const retryResponseStatuses = [ 504, // GatewayTimeout ]; -const temporarySearchPhaseExecutionExceptionReasons = [ - 'Search rejected due to missing shards', - 'all shards failed', -]; - export const catchRetryableEsClientErrors = ( e: EsErrors.ElasticsearchClientError ): Either.Either => { @@ -52,12 +47,7 @@ export const catchRetryableEsClientErrors = ( export const catchRetryableSearchPhaseExecutionException = ( e: EsErrors.ResponseError ): Either.Either => { - if ( - e?.body?.error?.type === 'search_phase_execution_exception' && - temporarySearchPhaseExecutionExceptionReasons.some((reason) => - e?.body?.error?.caused_by?.reason?.includes(reason) - ) - ) { + if (e?.body?.error?.type === 'search_phase_execution_exception') { return Either.left({ type: 'retryable_es_client_error' as const, message: e?.message, diff --git a/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_pickup_updated_mappings_task.ts b/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_pickup_updated_mappings_task.ts index 453d67249d38b..1b7d909c71ff8 100644 --- a/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_pickup_updated_mappings_task.ts +++ b/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_pickup_updated_mappings_task.ts @@ -38,10 +38,7 @@ export const waitForPickupUpdatedMappingsTask = flow( ); } else if (Option.isSome(res.error)) { const error = res.error.value; - if ( - error.type === 'search_phase_execution_exception' && - error.caused_by?.reason?.includes('Search rejected due to missing shards') - ) { + if (error.type === 'search_phase_execution_exception') { // This error is normally fixed in the next try, so let's retry // the update mappings task instead of throwing return TaskEither.left({ From 67e39afddcb9a31c3f3228ce24098deab564c93d Mon Sep 17 00:00:00 2001 From: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:07:34 +0000 Subject: [PATCH 2/2] Changes from node scripts/eslint_all_files --no-cache --fix --- .../trial_license_complete_tier/endpoint_exceptions.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/x-pack/solutions/security/test/security_solution_api_integration/test_suites/edr_workflows/artifacts/trial_license_complete_tier/endpoint_exceptions.ts b/x-pack/solutions/security/test/security_solution_api_integration/test_suites/edr_workflows/artifacts/trial_license_complete_tier/endpoint_exceptions.ts index 213ebfaba52d5..43151314bf099 100644 --- a/x-pack/solutions/security/test/security_solution_api_integration/test_suites/edr_workflows/artifacts/trial_license_complete_tier/endpoint_exceptions.ts +++ b/x-pack/solutions/security/test/security_solution_api_integration/test_suites/edr_workflows/artifacts/trial_license_complete_tier/endpoint_exceptions.ts @@ -180,7 +180,9 @@ export default function ({ getService }: FtrProviderContext) { }); describe(`and using Import API`, function () { - const buildImportBuffer = (listId: typeof ALL_ENDPOINT_ARTIFACT_LIST_IDS[number]): Buffer => { + const buildImportBuffer = ( + listId: (typeof ALL_ENDPOINT_ARTIFACT_LIST_IDS)[number] + ): Buffer => { const generator = new ExceptionsListItemGenerator(); const listInfo = Object.values(ENDPOINT_ARTIFACT_LISTS).find((listDefinition) => { return listDefinition.id === listId;