Skip to content

[stable-24.0.x] fix(chat): avoid ClassCastException when building FileParameters - #6481

Merged
mahibi merged 1 commit into
stable-24.0.xfrom
backport/6465/stable-24.0.x
Aug 11, 2026
Merged

[stable-24.0.x] fix(chat): avoid ClassCastException when building FileParameters#6481
mahibi merged 1 commit into
stable-24.0.xfrom
backport/6465/stable-24.0.x

Conversation

@backportbot

@backportbot backportbot Bot commented Aug 11, 2026

Copy link
Copy Markdown

Backport of PR #6465

  ChatMessageUi.messageParameters is built via Kotlin's toMap(), which
  returns a Collections.SingletonMap for a single entry instead of a
  HashMap. Both call sites unsafely cast it to
  HashMap<String?, HashMap<String?, String?>>?, which crashes whenever a
  message has exactly one rich-object parameter (e.g. a plain file
  share) - the common case for FileParameters.

  Build real HashMap instances from messageParameters instead of casting
  it. Also removes a runCatching block in
  LazyListState.visibleItemsWithThreshold() that silently swallowed the
  same ClassCastException, which was hiding this bug and causing file id
  lookups to fail there.

fixed crash:

❯ 2026-08-07 12:02:40.777 28629-28629 NextcloudT...pplication com.nextcloud.talk2                  E  Uncaught exception in thread "main" (Fix with AI)
                                                                                                      java.lang.ClassCastException: java.util.Collections$SingletonMap cannot be cast to
  java.util.HashMap
                                                                                                          at com.nextcloud.talk.ui.chat.MediaMessageKt.MediaMessage(MediaMessage.kt:71)
                                                                                                          at
  com.nextcloud.talk.ui.chat.ChatMessageViewKt.ChatMessageView$lambda$5$1(ChatMessageView.kt:151)
                                                                                                          at
  com.nextcloud.talk.ui.chat.ChatMessageViewKt.$r8$lambda$BiaHdWRFag7qJIfvY45CugWWbIY(ChatMessageView.kt:0)
                                                                                                          at
  com.nextcloud.talk.ui.chat.ChatMessageViewKt$$ExternalSyntheticLambda1.invoke(D8$$SyntheticClass:0)
                                                                                                          at
  androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:122)
                                                                                                          at
  androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:52)
                                                                                                          at
  com.nextcloud.talk.ui.chat.SwipeToReplyContainerKt.SwipeToReplyContainer(SwipeToReplyContainer.kt:57)
                                                                                                          at
  com.nextcloud.talk.ui.chat.ChatMessageViewKt.ChatMessageView$lambda$5(ChatMessageView.kt:114)
                                                                                                          at
  com.nextcloud.talk.ui.chat.ChatMessageViewKt$$ExternalSyntheticLambda4.invoke(D8$$SyntheticClass:0)
                                                                                                          at
  androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:122)
                                                                                                          at
  androidx.compose.runtime.internal.ComposableLambdaImpl.invoke(ComposableLambda.kt:52)
                                                                                                          at
  androidx.compose.runtime.CompositionLocalKt.CompositionLocalProvider(CompositionLocal.kt:408)
                                                                                                          at
  com.nextcloud.talk.ui.chat.ChatMessageViewKt.ChatMessageView(ChatMessageView.kt:105)

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
@backportbot
backportbot Bot requested review from mahibi and rapterjet2004 August 11, 2026 11:46
@backportbot backportbot Bot added 3. to review Waiting for reviews AI assisted labels Aug 11, 2026
@backportbot backportbot Bot added this to the 24.0.3 milestone Aug 11, 2026
@mahibi
mahibi merged commit 001530f into stable-24.0.x Aug 11, 2026
12 of 15 checks passed
@mahibi
mahibi deleted the backport/6465/stable-24.0.x branch August 11, 2026 12:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant