From f626135a3b05755c7ac2ca494a0207ebc127e884 Mon Sep 17 00:00:00 2001 From: Laura Trotta <153528055+l-trotta@users.noreply.github.com> Date: Wed, 12 Nov 2025 11:41:27 +0100 Subject: [PATCH] Async search error handling (#5597) * async search error handling * using common class --------- Co-authored-by: Quentin Pradet (cherry picked from commit 025a87b705c4be19d78fe814e3f6a22ae14e4812) --- .../_types/AsyncSearchResponseBase.ts | 15 +++++++++++++++ .../async_search/get/AsyncSearchGetResponse.ts | 11 ++++++++++- .../submit/AsyncSearchSubmitResponse.ts | 11 ++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/specification/async_search/_types/AsyncSearchResponseBase.ts b/specification/async_search/_types/AsyncSearchResponseBase.ts index 7449e8efa7..fb6cb834c5 100644 --- a/specification/async_search/_types/AsyncSearchResponseBase.ts +++ b/specification/async_search/_types/AsyncSearchResponseBase.ts @@ -18,6 +18,7 @@ */ import { Id } from '@_types/common' +import { ErrorCause } from '@_types/Errors' import { DateTime, EpochTime, UnitMillis } from '@_types/Time' import { AsyncSearch } from './AsyncSearch' @@ -48,9 +49,23 @@ export class AsyncSearchResponseBase { */ completion_time?: DateTime completion_time_in_millis?: EpochTime + error?: ErrorCause } export class AsyncSearchDocumentResponseBase< TDocument > extends AsyncSearchResponseBase { response: AsyncSearch } + +export class AsyncSearchResponseException { + is_partial: boolean + is_running: boolean + expiration_time?: DateTime + expiration_time_in_millis: EpochTime + start_time?: DateTime + start_time_in_millis: EpochTime + completion_time?: DateTime + completion_time_in_millis?: EpochTime + error?: ErrorCause + response?: AsyncSearch +} diff --git a/specification/async_search/get/AsyncSearchGetResponse.ts b/specification/async_search/get/AsyncSearchGetResponse.ts index 7c94fb4288..00f31e6e5d 100644 --- a/specification/async_search/get/AsyncSearchGetResponse.ts +++ b/specification/async_search/get/AsyncSearchGetResponse.ts @@ -17,9 +17,18 @@ * under the License. */ -import { AsyncSearchDocumentResponseBase } from '@async_search/_types/AsyncSearchResponseBase' +import { + AsyncSearchDocumentResponseBase, + AsyncSearchResponseException +} from '@async_search/_types/AsyncSearchResponseBase' export class Response { /** @codegen_name result */ body: AsyncSearchDocumentResponseBase + exceptions: [ + { + statusCodes: [404, 400, 500, 429] + body: AsyncSearchResponseException + } + ] } diff --git a/specification/async_search/submit/AsyncSearchSubmitResponse.ts b/specification/async_search/submit/AsyncSearchSubmitResponse.ts index 7c94fb4288..00f31e6e5d 100644 --- a/specification/async_search/submit/AsyncSearchSubmitResponse.ts +++ b/specification/async_search/submit/AsyncSearchSubmitResponse.ts @@ -17,9 +17,18 @@ * under the License. */ -import { AsyncSearchDocumentResponseBase } from '@async_search/_types/AsyncSearchResponseBase' +import { + AsyncSearchDocumentResponseBase, + AsyncSearchResponseException +} from '@async_search/_types/AsyncSearchResponseBase' export class Response { /** @codegen_name result */ body: AsyncSearchDocumentResponseBase + exceptions: [ + { + statusCodes: [404, 400, 500, 429] + body: AsyncSearchResponseException + } + ] }