diff --git a/package.json b/package.json index 4494faded4fee..1b57c74bb7b63 100644 --- a/package.json +++ b/package.json @@ -125,7 +125,7 @@ "@elastic/datemath": "5.0.3", "@elastic/ebt": "^1.2.1", "@elastic/ecs": "^8.11.5", - "@elastic/elasticsearch": "9.0.2", + "@elastic/elasticsearch": "9.0.3", "@elastic/ems-client": "8.6.3", "@elastic/eui": "104.0.2", "@elastic/eui-amsterdam": "npm:@elastic/eui@104.0.0-amsterdam.0", diff --git a/src/core/packages/saved-objects/api-server-internal/src/lib/apis/utils/internal_utils.ts b/src/core/packages/saved-objects/api-server-internal/src/lib/apis/utils/internal_utils.ts index 7380f2a5b0400..80fd9705fceab 100644 --- a/src/core/packages/saved-objects/api-server-internal/src/lib/apis/utils/internal_utils.ts +++ b/src/core/packages/saved-objects/api-server-internal/src/lib/apis/utils/internal_utils.ts @@ -38,7 +38,7 @@ export function getBulkOperationError( id: string, rawResponse: { status: number; - error?: { type: string; reason?: string; index: string }; + error?: { type: string; reason?: string | null; index: string }; // Other fields are present on a bulk operation result but they are irrelevant for this function } ): Payload | undefined { diff --git a/src/core/packages/saved-objects/migration-server-internal/src/actions/es_errors.ts b/src/core/packages/saved-objects/migration-server-internal/src/actions/es_errors.ts index 0ea6ccc227cba..d2c47e40a0fb1 100644 --- a/src/core/packages/saved-objects/migration-server-internal/src/actions/es_errors.ts +++ b/src/core/packages/saved-objects/migration-server-internal/src/actions/es_errors.ts @@ -41,7 +41,10 @@ export const isClusterShardLimitExceeded = (errorCause?: ErrorCause): boolean => ); }; -export const hasAllKeywordsInOrder = (message: string | undefined, keywords: string[]): boolean => { +export const hasAllKeywordsInOrder = ( + message: string | null | undefined, + keywords: string[] +): boolean => { if (!message || !keywords.length) { return false; } diff --git a/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_task.ts b/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_task.ts index 9fc717e2a5f0e..ca2bb26eb0b21 100644 --- a/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_task.ts +++ b/src/core/packages/saved-objects/migration-server-internal/src/actions/wait_for_task.ts @@ -20,7 +20,7 @@ import { /** @internal */ export interface WaitForTaskResponse { - error: Option.Option<{ type: string; reason?: string; index?: string }>; + error: Option.Option<{ type: string; reason?: string | null; index?: string }>; completed: boolean; failures: Option.Option; description?: string; diff --git a/src/core/packages/security/server/src/authentication/api_keys/api_keys.ts b/src/core/packages/security/server/src/authentication/api_keys/api_keys.ts index 56974f5dcf409..07d8c20fd74ed 100644 --- a/src/core/packages/security/server/src/authentication/api_keys/api_keys.ts +++ b/src/core/packages/security/server/src/authentication/api_keys/api_keys.ts @@ -203,10 +203,10 @@ export interface InvalidateAPIKeyResult { */ error_details?: Array<{ type?: string; - reason?: string; + reason?: string | null; caused_by?: { type?: string; - reason?: string; + reason?: string | null; }; }>; } diff --git a/x-pack/platform/packages/shared/ml/error_utils/src/process_errors.ts b/x-pack/platform/packages/shared/ml/error_utils/src/process_errors.ts index 49d4e81f51a11..a1a4b1006147c 100644 --- a/x-pack/platform/packages/shared/ml/error_utils/src/process_errors.ts +++ b/x-pack/platform/packages/shared/ml/error_utils/src/process_errors.ts @@ -75,7 +75,8 @@ export const extractErrorProperties = (error: ErrorType): MLErrorObject => { ) { errObj.causedBy = error.body.attributes.body.error.caused_by?.caused_by?.reason || - error.body.attributes.body.error.caused_by?.reason; + error.body.attributes.body.error.caused_by?.reason || + undefined; // Remove 'null' option from the types } if ( Array.isArray(error.body.attributes.body.error.root_cause) && diff --git a/x-pack/platform/plugins/shared/alerting/server/alert_deletion/lib/delete_alerts_for_query.ts b/x-pack/platform/plugins/shared/alerting/server/alert_deletion/lib/delete_alerts_for_query.ts index 71aa4425d3986..0ca7b000bbe37 100644 --- a/x-pack/platform/plugins/shared/alerting/server/alert_deletion/lib/delete_alerts_for_query.ts +++ b/x-pack/platform/plugins/shared/alerting/server/alert_deletion/lib/delete_alerts_for_query.ts @@ -104,7 +104,7 @@ export const deleteAlertsForQuery = async ( action: AlertAuditAction.DELETE, id: alertUuid, outcome: 'failure', - error: new Error(item.delete?.error?.reason), + error: new Error(item.delete?.error?.reason ?? undefined), // reason can be null and it's not a valid parameter for Error }) ); errors.push(`Error deleting alert "${alertUuid!}" - ${item.delete?.error?.reason}`); diff --git a/x-pack/platform/plugins/shared/fleet/server/services/agents/update_agent_tags_action_runner.ts b/x-pack/platform/plugins/shared/fleet/server/services/agents/update_agent_tags_action_runner.ts index 309aa80f4d8c2..a12e2dcddb05e 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/agents/update_agent_tags_action_runner.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/agents/update_agent_tags_action_runner.ts @@ -196,7 +196,7 @@ export async function updateTagsBatch( agentId: failure.id, actionId, namespace: spaceId, - error: failure.cause.reason, + error: failure.cause.reason ?? undefined, // reason can be null and we want to replace it with undefined })) ); appContextService.getLogger().debug(`action failed result wrote on ${failureCount} agents`); diff --git a/x-pack/platform/plugins/shared/fleet/server/services/artifacts/artifacts.ts b/x-pack/platform/plugins/shared/fleet/server/services/artifacts/artifacts.ts index 936e47a486884..f12ceefa5b5c6 100644 --- a/x-pack/platform/plugins/shared/fleet/server/services/artifacts/artifacts.ts +++ b/x-pack/platform/plugins/shared/fleet/server/services/artifacts/artifacts.ts @@ -227,7 +227,7 @@ export const bulkDeleteArtifacts = async ( if (res.errors) { errors = res.items.reduce((acc, item) => { if (item.delete?.error) { - acc.push(new Error(item.delete.error.reason)); + acc.push(new Error(item.delete.error.reason ?? undefined)); // reason can be null and it's not a valid parameter for Error } return acc; }, []); diff --git a/x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts b/x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts index edcee2f4f9ef1..25ab8ea5c03e2 100644 --- a/x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts +++ b/x-pack/platform/plugins/shared/ml/public/application/model_management/test_models/models/inference_base.ts @@ -393,7 +393,7 @@ export abstract class InferenceBase { if (doc === undefined) { if (error) { this.setFinishedWithErrors(error as unknown as MLHttpFetchError); - throw Error(error.reason); + throw Error(error.reason ?? undefined); // reason can be null and it's not a valid parameter for Error } throw Error( diff --git a/x-pack/platform/plugins/shared/task_manager/server/task_store.ts b/x-pack/platform/plugins/shared/task_manager/server/task_store.ts index df045724a9a4b..25b7661b18af2 100644 --- a/x-pack/platform/plugins/shared/task_manager/server/task_store.ts +++ b/x-pack/platform/plugins/shared/task_manager/server/task_store.ts @@ -634,7 +634,7 @@ export class TaskStore { if (item.update?.error) { const err = new BulkUpdateError({ - message: item.update.error.reason, + message: item.update.error.reason ?? undefined, // reason can be null, and we want to keep `message` as string | undefined type: item.update.error.type, statusCode: item.update.status, }); diff --git a/x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/utils/log_cluster_shard_failures_esql.test.ts b/x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/utils/log_cluster_shard_failures_esql.test.ts index f4eb8d89229a4..cf7c7a34a0401 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/utils/log_cluster_shard_failures_esql.test.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/lib/detection_engine/rule_types/utils/log_cluster_shard_failures_esql.test.ts @@ -42,7 +42,7 @@ describe('logClusterShardFailuresEsql', () => { it('should add warning message when shard failures exist in a single cluster', () => { const shardFailure: EsqlEsqlShardFailure = { reason: { type: 'test_failure', reason: 'test failure' }, - shard: '0', + shard: 0, index: 'test-index', }; @@ -70,13 +70,13 @@ describe('logClusterShardFailuresEsql', () => { it('should add warning message when shard failures exist in multiple clusters', () => { const shardFailure1: EsqlEsqlShardFailure = { reason: { type: 'test_failure_1', reason: 'test failure 1' }, - shard: '0', + shard: 0, index: 'test-index-1', }; const shardFailure2: EsqlEsqlShardFailure = { reason: { type: 'test_failure_2', reason: 'test failure 2' }, - shard: '1', + shard: 1, index: 'test-index-2', }; diff --git a/x-pack/solutions/security/plugins/security_solution/server/lib/types.ts b/x-pack/solutions/security/plugins/security_solution/server/lib/types.ts index 6d20331e770ab..403c0b597073c 100644 --- a/x-pack/solutions/security/plugins/security_solution/server/lib/types.ts +++ b/x-pack/solutions/security/plugins/security_solution/server/lib/types.ts @@ -27,12 +27,12 @@ export type ShardError = Partial<{ node: string; reason: Partial<{ type: string; - reason: string; + reason: string | null; index_uuid: string; index: string; caused_by: Partial<{ type: string; - reason: string; + reason: string | null; }>; }>; }>; diff --git a/yarn.lock b/yarn.lock index 5c460502e8b1f..6fff74a738b74 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2139,10 +2139,10 @@ "@elastic/transport" "^8.3.1" tslib "^2.4.0" -"@elastic/elasticsearch@9.0.2": - version "9.0.2" - resolved "https://registry.yarnpkg.com/@elastic/elasticsearch/-/elasticsearch-9.0.2.tgz#66fb8465fdeabb0c1174d3c48c0a2d5ad5d177c4" - integrity sha512-uKA0PuPSND3OhHH9UFqnKZfxifAg/8mQW4VnrQ+sUtusTbPhGuErs5NeWCPyd/RLgruBWBmLSv1zzEv5GS+UnA== +"@elastic/elasticsearch@9.0.3": + version "9.0.3" + resolved "https://registry.yarnpkg.com/@elastic/elasticsearch/-/elasticsearch-9.0.3.tgz#96302c6dfae27503d5271aba318883fdef4051bd" + integrity sha512-aagnssrVQi538wExO0Au169amtq68sXSwQMyzblQVAsqcmbqRTtzmGhKOjnDP0LK3ml0Mtje1uX+Vda7RhqDsA== dependencies: "@elastic/transport" "^9.0.1" apache-arrow "18.x - 19.x"