element-hq / element-hq/element-android
404 on .well-known/matrix/client handled incorrectly. Bad patch included
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
### Steps to reproduce
1. From app first boot with no data
2. Tap "Sign In"
3. Tap "Edit" to use a different homeserver
4. Type `consortium.chat` (or any homeserver where the `.well-known/matrix/client` responds with a 404 but is otherwise a normal homeserver)
5. Tap "Next"
### Outcome
#### What did you expect?
Sign-in continues as normal
#### What happened instead?
An error is shown: `.well-known is not available`

### Your phone model
Pixel 9 Pro
### Operating system version
Android 16
### Application version and app store
_No response_
### Homeserver
https://consortium.chat
### Will you send logs?
No
### Are you willing to provide a PR?
No
---
I am able to reproduce this in android studio, and this is a fix:
```patch
diff --git i/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt w/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt
index 003bdab9cb..e1b2f0307e 100644
--- i/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt
+++ w/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/wellknown/GetWellknownTask.kt
@@ -116,6 +116,12 @@ internal class DefaultGetWellknownTask @Inject constructor(
else -> WellknownResult.FailPrompt(null, null)
}
}
+ is Failure.ServerError -> {
+ when (throwable.httpCode) {
+ HttpsURLConnection.HTTP_NOT_FOUND -> WellknownResult.Ignore
+ else -> WellknownResult.FailPrompt(null, null)
+ }
+ }
is MalformedJsonException, is EOFException -> {
WellknownResult.FailPrompt(null, null)
}
```
But I'm sure it's not the *correct* fix as it duplicates code. I don't know enough kotlin to do this correctly. The issue is that the 404 logic is only implemented for `Failure.OtherServerError` whereas the exception thrown is a `Failure.ServerError`.
This also likely fixes #8950 and #8897 even though those are closed
Contributor guide
Assessment
This issue has not been assessed yet.