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)

(cherry picked from commit be24bfa)
  • Loading branch information
monusingh-1 authored and github-actions[bot] committed Dec 7, 2023
1 parent 712e21e commit b83622f
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")

Check warning on line 97 in src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt#L97

Added line #L97 was not covered by tests
}
if(!this::leaderIndex.isInitialized){
missingFields.add("leader_index")

Check warning on line 100 in src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt#L100

Added line #L100 was not covered by tests
}
if (!this::followerIndex.isInitialized){
missingFields.add("follower_index")

Check warning on line 103 in src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt#L103

Added line #L103 was not covered by tests
}
if(missingFields.isNotEmpty()){
validationException.addValidationError("Mandatory params $missingFields are missing for the request")
return validationException

Check warning on line 107 in src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt

View check run for this annotation

Codecov / codecov/patch

src/main/kotlin/org/opensearch/replication/action/index/ReplicateIndexRequest.kt#L106-L107

Added lines #L106 - L107 were not covered by tests
}

validateName(leaderIndex, validationException)
Expand Down

0 comments on commit b83622f

Please sign in to comment.