Skip to content

fix: Make Client.findDM return a Result #4816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 4, 2025

Conversation

jmartinesp
Copy link
Member

Content

What the title says. If finding the associated DM fails with an exception, the 'start DM' flow will fail too now.

Motivation and context

The SDK performs some checks on this function that can throw, so we need to guard the client.

I found this crash in the rageshakes:

Thread: main, Exception: org.matrix.rustcomponents.sdk.ClientException$Generic: msg=server name is not a valid IP address or domain name, details=InvalidServerName
at org.matrix.rustcomponents.sdk.FfiConverterTypeClientError.read(SourceFile:112)
at org.matrix.rustcomponents.sdk.FfiConverterTypeClientError.read(SourceFile:1)
at org.matrix.rustcomponents.sdk.FfiConverterRustBuffer$DefaultImpls.liftFromRustBuffer(SourceFile:13)
at org.matrix.rustcomponents.sdk.FfiConverterTypeClientError.liftFromRustBuffer(SourceFile:1)
at org.matrix.rustcomponents.sdk.FfiConverterRustBuffer$DefaultImpls.lift(SourceFile:6)
at org.matrix.rustcomponents.sdk.ClientException$ErrorHandler.lift(SourceFile:8)
at org.matrix.rustcomponents.sdk.Matrix_sdk_ffiKt.access$uniffiCheckCallStatus(SourceFile:123)
at io.element.android.libraries.matrix.impl.RustMatrixClient$findDM$2.invokeSuspend(SourceFile:124)

Tests

I'm not exactly sure how to test this other than adding a unit test.

Checklist

  • Changes have been tested on an Android device or Android emulator with API 24
  • UI change has been tested on both light and dark themes
  • Accessibility has been taken into account. See https://github.com/element-hq/element-x-android/blob/develop/CONTRIBUTING.md#accessibility
  • Pull request is based on the develop branch
  • Pull request title will be used in the release note, it clearly define what will change for the user
  • Pull request includes screenshots or videos if containing UI changes
  • You've made a self review of your PR

The SDK performs some checks on this function that can throw, so we need to guard the client.
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Jun 4, 2025
@jmartinesp jmartinesp requested a review from a team as a code owner June 4, 2025 07:38
@jmartinesp jmartinesp requested review from ganfra and removed request for a team June 4, 2025 07:38
Copy link
Contributor

github-actions bot commented Jun 4, 2025

📱 Scan the QR code below to install the build (arm64 only) for this PR.
QR code
If you can't scan the QR code you can install the build via this link: https://i.diawi.com/tpGcwL

Copy link
Member

@bmarty bmarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@@ -141,7 +141,8 @@ class UserProfilePresenterTest {
if (canFindRoom) {
givenGetRoomResult(A_ROOM_ID, room)
}
givenFindDmResult(dmRoom)
givenFindDmResult(Result.success(dmRoom))
givenFindDmResult(Result.success(dmRoom))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oups!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, will fix 😅

Copy link

sonarqubecloud bot commented Jun 4, 2025

@jmartinesp jmartinesp enabled auto-merge (squash) June 4, 2025 08:29
@jmartinesp jmartinesp merged commit 07af7cc into develop Jun 4, 2025
28 of 29 checks passed
@jmartinesp jmartinesp deleted the fix/find-dm-returns-result branch June 4, 2025 08:41
Copy link

codecov bot commented Jun 4, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 4 lines in your changes missing coverage. Please review.

Project coverage is 80.39%. Comparing base (efdc10e) to head (43cf693).
Report is 3 commits behind head on develop.

Files with missing lines Patch % Lines
.../android/libraries/matrix/impl/RustMatrixClient.kt 0.00% 3 Missing ⚠️
...ures/userprofile/impl/root/UserProfilePresenter.kt 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4816      +/-   ##
===========================================
- Coverage    80.39%   80.39%   -0.01%     
===========================================
  Files         2149     2149              
  Lines        56838    56842       +4     
  Branches      7126     7126              
===========================================
+ Hits         45697    45699       +2     
- Misses        8690     8691       +1     
- Partials      2451     2452       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR-Bugfix For bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants