element-hq / element-hq/element-android

404 on .well-known/matrix/client handled incorrectly. Bad patch included

Open
#9,056 0 comments 0 reactions 0 assignees View on GitHub
T-Defect
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`

![Image](https://github.com/user-attachments/assets/64023394-c062-4b52-94bb-e2c53fd82226)

### 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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.