Skip to content

Conversation

@jmartinesp
Copy link
Member

Content

Removes the setHomeserverUrl call when restoring a Client from its SessionData.

Motivation and context

This call isn't necessary and overrides the existing data previously saved by the SDK, resulting in losing data such as the Client::server (the discovery server URL).

In turn, this caused the app to be unable to refresh the server info in some homeservers. Sadly, this means users that are already logged in will be affected by this issue since their configured URLs would have been overridden after the first Client restoration, so they won't be able to refresh their server info until they log out and in again.

Tests

  • Freshly log into element.io or some other HS whose server URL doesn't match their HS URL (the host for the /.well-known/matrix/client doesn't match the actual HS).
  • Then clear the cache from the developer settings. You should not see this messages in the logs anymore:
matrix_sdk::client: Failed to fetch client well-known: the server returned an error: [404] <non-json bytes> | crates/matrix-sdk/src/client/mod.rs:1994

Also, if right after restoring the Client you add a log containing the Client.server() value, it should display the server URL instead of null.

Tested devices

  • Physical
  • Emulator
  • OS version(s): 16

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

This isn't necessary and overrides the existing data previously saved by the SDK, resulting in losing data such as the `Client::server` (the discovery server URL).

In turn, this caused the app to be unable to refresh the server info in some homeservers.
@jmartinesp jmartinesp requested a review from a team as a code owner November 18, 2025 07:02
@jmartinesp jmartinesp added the PR-Bugfix For bug fix label Nov 18, 2025
@jmartinesp jmartinesp requested review from bmarty and removed request for a team November 18, 2025 07:02
@github-actions
Copy link
Contributor

📱 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/21Q346

@sonarqubecloud
Copy link

@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.65%. Comparing base (ac0e39c) to head (56bd618).
⚠️ Report is 14 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #5753   +/-   ##
========================================
  Coverage    79.65%   79.65%           
========================================
  Files         2434     2434           
  Lines        65454    65453    -1     
  Branches      8341     8341           
========================================
  Hits         52136    52136           
+ Misses       10341    10340    -1     
  Partials      2977     2977           

☔ 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.

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.

Thanks!

passphrase = sessionData.passphrase,
slidingSyncType = ClientBuilderSlidingSync.Restored,
)
.homeserverUrl(sessionData.homeserverUrl)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the fix!
So it seems that the application is storing the actual homeserver Url (CS baseUrl) and this is not really expected. I was looking at the other usage of homeserverUrl (to see if it could be just removed) and I see that the only other usage of homeserverUrl is here, and toSession is invoked at line 73 below.

So it is actually OK that the CS baseUrl is stored?

Copy link
Member

Choose a reason for hiding this comment

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

The other usage is actually not used by the SDK. Maybe some cleanup can be done SDK side later.

Copy link
Member Author

Choose a reason for hiding this comment

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

The other usage is actually not used by the SDK. Maybe some cleanup can be done SDK side later.

This was implemented in matrix-org/matrix-rust-sdk#5874.

@jmartinesp jmartinesp merged commit 21ced9e into develop Nov 18, 2025
36 of 37 checks passed
@jmartinesp jmartinesp deleted the fix/dont-override-homeserver-when-restoring-client branch November 18, 2025 10:48
jmartinesp added a commit that referenced this pull request Nov 18, 2025
jmartinesp added a commit that referenced this pull request Nov 18, 2025
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.

3 participants