Skip to content
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

Failed to prepare profile (Avatar) error while account already had avatar #12

Open
dreamtwi opened this issue Sep 21, 2024 · 3 comments

Comments

@dreamtwi
Copy link

dreamtwi commented Sep 21, 2024

The first login was successful. However, on the second login attempt, since the avatar was already created during the first login, the process continuously repeats and gets stuck in the following error:
2024-09-21T15:02:16.359433Z DEBUG ThreadId(01) baibot::bot::implementation: src/bot/implementation.rs:264: Preparing profile..
2024-09-21T15:02:17.259867Z WARN ThreadId(01) baibot::bot::implementation: src/bot/implementation.rs:249: Failed to prepare profile.. Will retry after delay... err=Failed fetching existing avatar: Http(Api(Server(ClientApi(Error { status_code: 404, body: Standard { kind: NotFound, message: "Not found" } })))) delay=3s

The homeserver I used is matrix.org

@spantaleev
Copy link
Contributor

Despite the bot having done its avatar setup already, it can't know its current avatar is what it expects it to be, so it does a profile check (preparation) every time it starts. If it notices that its name is out-of-sync with the configuration, or its avatar is not what it expects it to be (there's a single image hardcoded in the binary), it will update its profile.

So it checking its profile on every startup is not an issue. It's supposed to do it successfully.


Does it keep retrying unsuccessfully for you?

You can try enabling more verbose logging (trace) and see if you get anything else.

It's odd that it's getting a "not found" error. It almost sounds like the homeserver is down, but.. it shouldn't be, because before the profile preparation work, the underlying library (mxlink) actually does a "who am I" check to ensure the access token is still valid. So the homeserver should have been confirmed working just a moment ago before trying to prepare the profile.

@dreamtwi
Copy link
Author

After some research, I suspect the issue might be caused by calling deprecated API.

From the log:

2024-09-21T15:21:23.117874Z DEBUG ThreadId(01) send{server_versions=[V1_0, V1_1, V1_2, V1_3, V1_4, V1_5, V1_6, V1_7, V1_8] config=RequestConfig { timeout: 30s } request_id="REQ-4" method=GET uri="https://matrix-client.matrix.org/_matrix/media/v3/download/matrix.org/ASnMqdmQZekIDpkbzERvSBFf" status=404 response_size="45 B"}: matrix_sdk::http_client: /cargo/registry/src/index.crates.io-6f17d22bba15001f/matrix-sdk-0.7.1/src/http_client/mod.rs:186: Error while sending request: Api(Server(ClientApi(Error { status_code: 404, body: Standard { kind: NotFound, message: "Not found" } })))

The API is using _matrix/media/v3/download/matrix.org, which is deprecated. According to the Matrix API playground and the specification, this endpoint may return a 404 M_NOT_FOUND error for media that exists but is inaccessible due to the server freezing unauthenticated media access.

I suspect this might be the cause. Not sure if anyone else is experiencing the same problem?

@spantaleev
Copy link
Contributor

This is caused by the latest matrix-rust-sdk release (v0.7.1) being too out-of-date and not supporting authenticated media.

The matrix.org server has disabled unauthenticated media already. Other servers are soon to follow as well.

We have a few other features that deal with file downloads/uploads, which would also be broken due to this.


Authenticated media support already appears to be working upstream (in ruma and matrix-rust-sdk), but there's no matrix-rust-sdk release yet. The last one is from 8 months ago.

Hopefully, the matrix-rust-sdk folks will cut a new release (v0.8?) soon which we can switch to. I've pinged them about it here: matrix-org/matrix-rust-sdk#3742 (comment)

spantaleev added a commit that referenced this issue Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants