From be24bfaa9a795179662a6660633902a7737b717c Mon Sep 17 00:00:00 2001 From: Monu Singh Date: Thu, 7 Dec 2023 17:06:48 +0530 Subject: [PATCH] Correct error message when field are not passed when starting replication (#1292) --- .../action/index/ReplicateIndexRequest.kt | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt index 6024798a..3d2bfb1b 100644 --- a/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt +++ b/src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt @@ -92,10 +92,19 @@ class ReplicateIndexRequest : AcknowledgedRequest, Indice override fun validate(): ActionRequestValidationException? { var validationException = ActionRequestValidationException() - if (!this::leaderAlias.isInitialized || - !this::leaderIndex.isInitialized || - !this::followerIndex.isInitialized) { - validationException.addValidationError("Mandatory params are missing for the request") + val missingFields: MutableList = mutableListOf() + if (!this::leaderAlias.isInitialized){ + missingFields.add("leader_alias") + } + if(!this::leaderIndex.isInitialized){ + missingFields.add("leader_index") + } + if (!this::followerIndex.isInitialized){ + missingFields.add("follower_index") + } + if(missingFields.isNotEmpty()){ + validationException.addValidationError("Mandatory params $missingFields are missing for the request") + return validationException } validateName(leaderIndex, validationException)