Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct error message when field are not passed when starting replication #1292

Merged
merged 2 commits into from
Dec 7, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,19 @@
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
Loading