{"record":{"id":"01e553a5deb334eb","repo":"quarkusio/quarkus","slug":"unexpected-index-index-01e553","errorCode":null,"errorMessage":"Unexpected index $index","messagePattern":"Unexpected index \\$index","errorType":"exception","errorClass":"SerializationException","httpStatus":null,"severity":"error","filePath":"extensions/resteasy-reactive/rest-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/resteasy/reactive/kotlin/serialization/runtime/ViolationReportViolationSerializer.kt","lineNumber":34,"sourceCode":"    override val descriptor: SerialDescriptor =\n        buildClassSerialDescriptor(\n            \"io.quarkus.hibernate.validator.runtime.jaxrs.ViolationReport.Violation\"\n        ) {\n            element(\"field\", serialDescriptor<String>())\n            element(\"message\", serialDescriptor<String>())\n        }\n\n    override fun deserialize(decoder: Decoder): ViolationReport.Violation {\n        return decoder.decodeStructure(descriptor) {\n            var field: String? = null\n            var message: String? = null\n\n            loop@ while (true) {\n                when (val index = decodeElementIndex(descriptor)) {\n                    CompositeDecoder.DECODE_DONE -> break@loop\n                    0 -> field = decodeStringElement(descriptor, 0)\n                    1 -> message = decodeStringElement(descriptor, 1)\n                    else -> throw SerializationException(\"Unexpected index $index\")\n                }\n            }\n\n            ViolationReport.Violation(requireNotNull(field), requireNotNull(message))\n        }\n    }\n\n    override fun serialize(encoder: Encoder, value: ViolationReport.Violation) {\n        encoder.encodeStructure(descriptor) {\n            encodeStringElement(descriptor, 0, value.field)\n            encodeStringElement(descriptor, 1, value.message)\n        }\n    }\n}\n","sourceCodeStart":16,"sourceCodeEnd":49,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/resteasy-reactive/rest-kotlin-serialization/runtime/src/main/kotlin/io/quarkus/resteasy/reactive/kotlin/serialization/runtime/ViolationReportViolationSerializer.kt#L16-L49","documentation":"ViolationReportViolationSerializer deserializes Violation.Violation entries expecting exactly two elements: index 0 = field, index 1 = message. Any other index reached in the decode loop throws SerializationException(\"Unexpected index $index\").","triggerScenarios":"Deserializing a violation entry JSON object with more/unknown keys than `field` and `message`, producing element indices beyond 1 in the strict decoder.","commonSituations":"Bean Validation reports produced by a different Quarkus/RESTEasy version with additional properties; clients sending extended violation objects; strict Json configuration without ignoreUnknownKeys.","solutions":["Restrict violation JSON entries to only `field` and `message` keys","Use Json { ignoreUnknownKeys = true } for decoding external payloads","Align producer and consumer versions of the violation report schema"],"exampleFix":"// before\nval json = Json\n// after\nval json = Json { ignoreUnknownKeys = true }","handlingStrategy":"try-catch","validationCode":"val allowed = setOf(\"field\", \"message\")\nrequire(entry.keys().all { it in allowed }) { \"Unknown keys in violation entry\" }","typeGuard":null,"tryCatchPattern":"try {\n    Json.decodeFromString(ViolationReportViolationSerializer, body)\n} catch (e: SerializationException) {\n    Json { ignoreUnknownKeys = true }.decodeFromString(ViolationReportViolationSerializer, body)\n}","preventionTips":["Restrict violation entries to field/message keys on the producer side","Use lenient Json configuration when consuming unknown sources","Pin matching Quarkus versions across services sharing the schema"],"tags":["kotlin","kotlinx-serialization","deserialization","validation","resteasy-reactive"],"backgroundTag":"unexpected-field-deserialization","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}