-
Notifications
You must be signed in to change notification settings - Fork 662
Open
Description
Describe the bug
I get java.lang.ArrayIndexOutOfBoundsException when try to deserialize following json. It has started when I added coerceInputValues = true to my Json
{
"messageId": 34190,
"chatId": 4819,
"dateCreate": {
"gmtTimeUnit": {
"type": "com.merseyside.merseyLib.time.units.Millis",
"millis": 1760946587000
},
"timeZone": {
"zoneId": "Europe/Amsterdam",
"offset": {
"type": "com.merseyside.merseyLib.time.units.Seconds",
"millis": 10800000
}
}
},
"dateLastComment": null,
"dateStatusSet": null,
"hasNew": false,
"headMessageId": null,
"isPinned": false,
"isQuiet": false,
"lastCommentId": null,
"allowAddComment": false,
"orderId": null,
"reactionId": null,
"receiverAccountId": null,
"replyBody": "",
"replyMessageId": null,
"replyAccountId": null,
"senderAccountId": 1,
"totalCommentCount": 0,
"unreadCommentCount": 0,
"viewsCount": 0,
"status": 1,
"reactions": [],
"edited": false,
"body": "body",
"direction": "out",
"files": [],
"uuid": null,
"isNewMessage": false,
"links": [],
"showOrderAsReply": false,
"prevMessageId": 34189
}
@OptIn(ExperimentalSerializationApi::class)
@Serializer(forClass = ChatMessageModel::class)
object MessagesSerializer
this is my model generated by sqldelight.
public data class ChatMessageModel(
public val messageId: Long,
public val chatId: Long,
public val dateCreate: ZonedTimeUnit,
public val dateLastComment: ZonedTimeUnit?,
public val dateStatusSet: ZonedTimeUnit?,
public val hasNew: Boolean,
public val headMessageId: Long?,
public val isPinned: Boolean,
public val isQuiet: Boolean,
public val lastCommentId: Long?,
public val allowAddComment: Boolean,
public val orderId: Long?,
public val reactionId: Long?,
public val receiverAccountId: Long?,
public val replyBody: String?,
public val replyMessageId: Long?,
public val replyAccountId: Long?,
public val senderAccountId: Long,
public val totalCommentCount: Long,
public val unreadCommentCount: Long,
public val viewsCount: Long,
public val status: MessageStatus,
public val reactions: ReactionStatistic,
public val edited: Boolean,
public val body: String,
public val direction: MessageDirection,
public val files: List<File>,
public val uuid: String?,
public val isNewMessage: Boolean,
public val links: List<LinkModel>?,
public val showOrderAsReply: Boolean,
public val prevMessageId: Long?,
)
java.lang.ArrayIndexOutOfBoundsException: length=0; index=0
at kotlinx.serialization.internal.PluginGeneratedSerialDescriptor.getElementDescriptor(PluginGeneratedSerialDescriptor.kt:135)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.coerceInputValue(StreamingJsonDecoder.kt:423)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeObjectIndex(StreamingJsonDecoder.kt:231)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeElementIndex(StreamingJsonDecoder.kt:178)
at ru.izibook.chats.db.MessagesSerializer.deserialize(MessagesSerializer.kt:7)
at ru.izibook.chats.db.MessagesSerializer.deserialize(MessagesSerializer.kt:7)
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:69)
at kotlinx.serialization.json.Json.decodeFromString(Json.kt:149)
at com.merseyside.merseyLib.kotlin.serialization.SerializationKt.deserialize(Serialization.kt:50)
at com.merseyside.merseyLib.kotlin.serialization.SerializationKt.deserialize$default(Serialization.kt:46)
at ru.izibook.chats.db.DbKt$special$$inlined$getSerializableColumnAdapter$3.decode(ColumnAdapterBuilder.kt:16)
at ru.izibook.chats.db.DbKt$special$$inlined$getSerializableColumnAdapter$3.decode(ColumnAdapterBuilder.kt:12)
at ru.izibook.chats.db.model.ChatLastMessageQueries.getMessage$lambda$0(ChatLastMessageQueries.kt:20)
at ru.izibook.chats.db.model.ChatLastMessageQueries.$r8$lambda$KwmQqFJqq7_JQ3bkGGpmjqQFNLA(Unknown Source:0)
at ru.izibook.chats.db.model.ChatLastMessageQueries$$ExternalSyntheticLambda5.invoke(D8$$SyntheticClass:0)
at app.cash.sqldelight.ExecutableQuery.executeAsOneOrNull$lambda$2(Query.kt:200)
Environment
- Kotlin version: 2.2.21
- Library version: 1.9.0
- Kotlin platforms: KMP [Android]
- Gradle version: 9.1.0
- IDE version Android Studio Otter 2 Feature Drop | 2025.2.2 Canary 1
Metadata
Metadata
Assignees
Labels
No labels