matrix-org / matrix-org/matrix-rust-sdk

Removing an avatar does not update the cached value.

Open
#5,285 1 comment 1 reaction 0 assignees View on GitHub
sliding-sync
Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

Original issue: https://github.com/element-hq/element-x-ios/issues/4117

To explain the issue I'll add two sync responses, one for when the avatar is updated with a new avatar URL, and another one when the avatar is updated with a null value.

## Updated the room avatar with a new avatar
```
{
"pos": "92278017/s6020200519_757284974_6174708_3755728849_4242429717_265999676_1501755517_11151313124_0_501813",
"lists": {
"all_rooms": {
"count": 1,
"ops": [
{
"op": "SYNC",
"range": [
0,
0
],
"room_ids": [
"!yaCGbiOMYrDStgWeJr:matrix.org"
]
}
]
}
},
"rooms": {
"!yaCGbiOMYrDStgWeJr:matrix.org": {
"notification_count": 0,
"highlight_count": 0,
"avatar": "mxc://matrix.org/vIjDaVKBEbwZnqWgGCUICiFZ",
"timeline": [
{
"content": {
"info": {
"mimetype": "image/jpeg"
},
"url": "mxc://matrix.org/vIjDaVKBEbwZnqWgGCUICiFZ"
},
"origin_server_ts": 1750870056555,
"sender": "@mauro-fresh-test:matrix.org",
"state_key": "",
"type": "m.room.avatar",
"unsigned": {
"replaces_state": "$ZhOcRvDWYId3ezMib5reiI3UhIDcdElU74ke3snQF0o",
"prev_content": {
"info": {
"mimetype": "image/jpeg"
},
"url": "mxc://matrix.org/LyxCQrNKUopMetbFJnAMbuwE"
},
"prev_sender": "@mauro-fresh-test:matrix.org",
"membership": "join",
"age": 253
},
"event_id": "$h9cbzBomcAA48mip7UhKfgU7f6EXIrL0nMuYfFAfOG0"
}
],
"limited": false,
"prev_batch": "s6020200518_757284974_6174708_3755728849_4242429717_265999676_1501755517_11151313124_0_501813",
"num_live": 1
}
},
"extensions": {
"account_data": {
"global": [],
"rooms": {}
},
"receipts": {
"rooms": {}
},
"typing": {
"rooms": {}
}
}
}

```
Everything works fine, the avatar gets updated and the new avatar is correctly displayed in the `RoomInfo` and in the room list

## After an avatar has been removed
```
{
"pos": "92278017/m6020205333~36.6020205358~2.6020205361~37.6020205358~1.6020205359_757284974_6183177_m3755734258~38.3755734261~75.3755734262~39.3755734261_4242436499_265999688_1501755866_11151313705_0_501816",
"lists": {
"all_rooms": {
"count": 1,
"ops": [
{
"op": "SYNC",
"range": [
0,
0
],
"room_ids": [
"!yaCGbiOMYrDStgWeJr:matrix.org"
]
}
]
}
},
"rooms": {
"!yaCGbiOMYrDStgWeJr:matrix.org": {
"notification_count": 0,
"highlight_count": 0,
"timeline": [
{
"content": {
"url": null
},
"origin_server_ts": 1750870173350,
"sender": "@mauro-fresh-test:matrix.org",
"state_key": "",
"type": "m.room.avatar",
"unsigned": {
"replaces_state": "$h9cbzBomcAA48mip7UhKfgU7f6EXIrL0nMuYfFAfOG0",
"prev_content": {
"info": {
"mimetype": "image/jpeg"
},
"url": "mxc://matrix.org/vIjDaVKBEbwZnqWgGCUICiFZ"
},
"prev_sender": "@mauro-fresh-test:matrix.org",
"membership": "join",
"age": 325
},
"event_id": "$VzfssgMRWyDhHcPqcLiSr3_9GjZIF8Cpv9CF0hztmzU"
}
],
"limited": false,
"prev_batch": "s6020205358_757284974_6183177_m3755734258~38.3755734261~75.3755734262~39.3755734261_4242436499_265999688_1501755866_11151313705_0_501816",
"num_live": 1
}
},
"extensions": {
"account_data": {
"global": [],
"rooms": {}
},
"receipts": {
"rooms": {}
},
"typing": {
"rooms": {}
}
}
}
```
What happens in this case is that the cache still keeps the existing avatar, my feeling is that the SDK is not able to differentiate between a null value, and no value present at all, which makes the cache ignore the avatar update and removing it.
Clearing the cache solves the issue and restores the empty avatar in fact.

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the two provided sync responses and trace how the SDK handles the room avatar when the event content contains a null URL. Verify that the cache removes the previous avatar without requiring a cache clear, and confirm that the empty avatar is then shown in the room list and RoomInfo.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.