Skip to content

Commit

Permalink
Correct error message when field are not passed when starting replica…
Browse files Browse the repository at this point in the history
…tion (#1292) (#1293)
  • Loading branch information
opensearch-trigger-bot[bot] authored Dec 7, 2023
1 parent 712e21e commit 95028c8
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@ class ReplicateIndexRequest : AcknowledgedRequest<ReplicateIndexRequest>, 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<String> = 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)
Expand Down

0 comments on commit 95028c8

Please sign in to comment.