PM-27770: Update error parsing when creating or updating a cipher (#6118)

This commit is contained in:
David Perez 2025-11-04 13:08:10 -06:00 committed by GitHub
parent 4b7fcdb6ea
commit 14e833247d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 19 additions and 12 deletions

View File

@ -91,7 +91,10 @@ class CipherManagerImpl(
.map { response ->
when (response) {
is CreateCipherResponseJson.Invalid -> {
CreateCipherResult.Error(errorMessage = response.message, error = null)
CreateCipherResult.Error(
errorMessage = response.firstValidationErrorMessage,
error = null,
)
}
is CreateCipherResponseJson.Success -> {
@ -131,7 +134,10 @@ class CipherManagerImpl(
.map { response ->
when (response) {
is CreateCipherResponseJson.Invalid -> {
CreateCipherResult.Error(errorMessage = response.message, error = null)
CreateCipherResult.Error(
errorMessage = response.firstValidationErrorMessage,
error = null,
)
}
is CreateCipherResponseJson.Success -> {
@ -301,7 +307,10 @@ class CipherManagerImpl(
.map { response ->
when (response) {
is UpdateCipherResponseJson.Invalid -> {
UpdateCipherResult.Error(errorMessage = response.message, error = null)
UpdateCipherResult.Error(
errorMessage = response.firstValidationErrorMessage,
error = null,
)
}
is UpdateCipherResponseJson.Success -> {
@ -581,9 +590,7 @@ class CipherManagerImpl(
.flatMap { response ->
when (response) {
is UpdateCipherResponseJson.Invalid -> {
IllegalStateException(
response.message,
)
IllegalStateException(response.firstValidationErrorMessage)
.asFailure()
}

View File

@ -24,9 +24,9 @@ sealed class CreateCipherResponseJson {
@Serializable
data class Invalid(
@SerialName("message")
val message: String?,
override val message: String,
@SerialName("validationErrors")
val validationErrors: Map<String, List<String>>?,
) : CreateCipherResponseJson()
override val validationErrors: Map<String, List<String>>?,
) : CreateCipherResponseJson(), InvalidJsonResponse
}

View File

@ -25,9 +25,9 @@ sealed class UpdateCipherResponseJson {
@Serializable
data class Invalid(
@SerialName("message")
val message: String?,
override val message: String,
@SerialName("validationErrors")
val validationErrors: Map<String, List<String>>?,
) : UpdateCipherResponseJson()
override val validationErrors: Map<String, List<String>>?,
) : UpdateCipherResponseJson(), InvalidJsonResponse
}