Repository navigation
Fix a crash on custom room membership and map missing SDK fields - #8252
Conversation
RoomMemberMapper.mapMembership mapped MembershipState.Custom to TODO(), which throws NotImplementedError when the SDK returns a member with a non-standard membership value. Map it to LEAVE instead, so the member is not considered active, and log the unknown value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RoomPreviewInfo from the SDK exposes isDirect, heroes and numActiveMembers but we never mapped them, so JoinRoomPresenter hardcoded isDm = false for room previews and an empty hero list for space previews. Map the three fields into the api RoomPreviewInfo, derive isDm from them (direct room with at most 2 active members, like the SDK does for RoomInfo), and use isDm and heroes when building the join room content state from a preview. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
EventTimelineItem from the SDK exposes redactionReason, the reason given with the redaction of an event (from the server, or from our own pending redaction), but it was dropped by EventTimelineItemMapper. Expose it as EventTimelineItem.redactionReason in the matrix api so the timeline can later show why a message was removed. No UI change yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The SDK reports isRecoverable on EventSendState.SendingFailed and on RoomSendQueueUpdate.SendError, but we dropped it, so the app could not tell a failure that disabled the send queue from one parked until the user retries or cancels it. Expose it as LocalEventSendState.Failed.isRecoverable, set on every failure subtype without a default so the mapper cannot drop it again, and as SendQueueUpdate.SendError.isRecoverable. SendingFromUnverifiedDevice and MissingMediaContent become data classes to carry the value, and the verified user failure iterators keep it when splitting a failure. No UI change yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
📱 Scan the QR code below to install the build (arm64 only) for this PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #8252 +/- ##
===========================================
+ Coverage 81.11% 81.13% +0.02%
===========================================
Files 2906 2906
Lines 87593 87614 +21
Branches 11906 11897 -9
===========================================
+ Hits 71052 71088 +36
+ Misses 11900 11889 -11
+ Partials 4641 4637 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Document the transactionId parameter of SendQueueUpdate.SendError (OutdatedDocumentation) and remove unnecessary parentheses in RoomPreviewInfo.isDm (UnnecessaryParentheses). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
jmartinesp
left a comment
There was a problem hiding this comment.
Thanks! I was a bit worried because I remember making some exceptions for isRecoverable in the send queue errors, but I don't think this affects it.
| ) | ||
| } | ||
| is QueueWedgeError.GenericApiError -> { | ||
| LocalEventSendState.Failed.Unknown(queueWedgeError.msg) |
There was a problem hiding this comment.
This is what I was talking about in the approval comment:
There was a problem hiding this comment.
Thanks for the heads up. This PR is just adding the mapping, there is no behavior change.



Content
We audited the data classes of
org.matrix.rustcomponents:sdk-android:26.11.18-nightlyagainst the mappers inlibraries/matrix/impl, looking for SDK fields we never map. This PR fixes the crash the audit found and maps the three fields with the clearest value for the app. Each change is a separate commit:RoomMemberMapper.mapMembershipmappedMembershipState.CustomtoTODO(), so any member with a non-standard membership crashed the app. It is now mapped toLEAVE, so the member is not considered active, and the unknown value is logged.RoomPreviewInfonow mapsisDirect,heroesandnumActiveMembers.JoinRoomPresenterhardcodedisDm = falsefor room previews and an empty hero list for space previews; it now uses the real values.isDmis derived as "direct room with at most 2 active members".EventTimelineItem.redactionReason. Mapping only, no UI yet.isRecoverableon everyLocalEventSendState.Failedsubtype and onSendQueueUpdate.SendError. It has no default value, so a mapper cannot silently drop it.SendingFromUnverifiedDeviceandMissingMediaContentchange fromdata objecttodata class. Mapping only, no UI yet.Motivation and context
The SDK keeps adding fields that never reach our models, so the UI can't use data the SDK already provides, and one gap was a crash.
Status of the other unmapped SDK fields
Found by the audit, not handled in this PR:
Useful for the UI, candidates for follow-up PRs
EventTimelineItem.redactionReason(UI)TimelineItemRedactedContentthat carries the reasonFailed.isRecoverable/SendError.isRecoverable(UI)LocationContent.zoomLevelTimeline.sendLocation) but drop it on receiveMessageLikeEventContent.RoomMessage.inReplyToEventIdPasswordStrengthEstimate.feedbackEventTimelineItem.localCreatedAtReactionSenderData.sendStateVideoMessageContent.circle/VideoInfo.circleEventSendState.SendingFailed.erroronSendQueueUpdate.SendErrorLow value, map when a feature needs them
RoomInfo/NotificationRoomInfo:activeServiceMembersCount,serviceMembers. Service members are already flagged per member (RoomMember.isServiceMember).NotificationRoomInfo:canonicalAlias,topic,joinedMembersCount.OtherState.RoomPowerLevels:events,previousEvents,previousUsers,thresholds,previousThresholds. Only needed for richer state event text.OtherState.RoomCreate.federate,OtherState.RoomHistoryVisibility.historyVisibility. Same.RoomPowerLevelsValues.usersDefault.RoomPowerLevelChanges.usersDefaultis also always sent asnull.RecentEmoji.count. Onlyemojiis kept.ComposerDraft.attachments. AlwaysemptyList(), so drafts lose their attachments.Debug or internal, no need to map
EventTimelineItem.eventTypeRaw,NotificationItem.rawEvent,NotificationItem.actionsEventEncryptionInfo:senderId,senderCurve25519Key,sessionId,shieldStateStrictPasswordStrengthEstimate.guesses,StickyEvent.expiresAtMsSDK parameters we never set (defaults are used):
extraContentJsonon upload and gallery parameters, seven options ofVirtualElementCallWidgetConfig,expecton theCategoryandReadReceiptsroom list filters.Fields with very common names (
name,topic, ...) can hide a gap from the audit, so these lists may be incomplete.Screenshots / GIFs
No visual change in previews. Item 2 changes what the join room screen shows when it previews an unknown DM or space.
Tests
RoomMemberMapperTest,RoomPreviewInfoMapperTest,RoomPreviewInfoTest,JoinRoomPresenterTest,EventTimelineItemMapperTest,SendQueueUpdatesExtTest./gradlew :libraries:matrix:impl:testDebugUnitTest :features:messages:impl:testDebugUnitTestpassesTested devices
Checklist
🤖 Generated with Claude Code