Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

/joined_members incorrectly says the appservice wasn't in the room #7373

Closed
Sorunome opened this issue Apr 30, 2020 · 2 comments
Closed

/joined_members incorrectly says the appservice wasn't in the room #7373

Sorunome opened this issue Apr 30, 2020 · 2 comments
Labels
A-Application-Service Related to AS support z-bug (Deprecated Label) z-p2 (Deprecated Label)

Comments

@Sorunome
Copy link
Contributor

Sorunome commented Apr 30, 2020

Description

When trying to call /joined_members synapse incorrectly claims that the appservice wasn't in the room. While the appservice bot itself is indeed not in the room, the ghost set in the user_id query parameter is.

sorunome@sorunome-desktop ~ $ curl -H "Authorization: Bearer 0d1dcaae-26db-4810-b284-48df4223328e" "http://192.168.1.13:8008/_matrix/client/r0/rooms/%21KiNzXZsRUASeNmbTVD%3A192.168.1.13/joined_members?user_id=%40_botty_n%3D2cj1x3ls3e_42sq9ub%3A192.168.1.13"
{
    "joined": {
        "@_botty_n=2cj1x3ls3e_42sq9ub:192.168.1.13": {
            "avatar_url": "mxc://192.168.1.13/SFPimpzstdTNxFuIoxwClVRV",
            "display_name": "Fuchs Rolle!!!"
        },
        "@test:192.168.1.13": {
            "avatar_url": "mxc://192.168.1.13/YKbcxzDWAYgwrdegzQZmFMYX",
            "display_name": "test"
        }
    }
}
sorunome@sorunome-desktop ~ $ curl -X PUT -H "Authorization: Bearer 0d1dcaae-26db-4810-b284-48df4223328e" -H "Content-Type: application/json" -d '{"beep": "boop"}' "http://192.168.1.13:8008/_matrix/client/r0/rooms/%21KiNzXZsRUASeNmbTVD%3A192.168.1.13/state/de.sorunome.custom/%40_botty_n%3D2cj1x3ls3e_42sq9ub%3A192.168.1.13?user_id=%40_botty_n%3D2cj1x3ls3e_42sq9ub%3A192.168.1.13" 
{
    "event_id": "$nfrfZ-FtF1LLJZAPjfVYoSHplI0tkNeQ3GSCGi5wjig"
}
sorunome@sorunome-desktop ~ $ curl -H "Authorization: Bearer 0d1dcaae-26db-4810-b284-48df4223328e" "http://192.168.1.13:8008/_matrix/client/r0/rooms/%21KiNzXZsRUASeNmbTVD%3A192.168.1.13/joined_members?user_id=%40_botty_n%3D2cj1x3ls3e_42sq9ub%3A192.168.1.13"
{
    "errcode": "M_FORBIDDEN",
    "error": "Appservice not in room"
}

(The appservice token is only for a local install)

Steps to reproduce

  • start synapse
  • call /joined_members as an appservice ghost that the ghost is in --> it returns the results just fine
  • set a state event as said ghost with the state_key being its mxid. This needs to actually create a new / modify the existing state, else the bug won't trigger
  • call again /joined_members, synapse now claims the appservice wasn't in the room until a restart occurs

Version information

  • Version:
sorunome@sorunome-desktop ~ $ curl http://localhost:8008/_synapse/admin/v1/server_version
{
    "python_version": "3.8.2",
    "server_version": "1.12.4 (b=master,204664d1a)"
}
  • Install method:
    git clone

  • Platform:
    archlinux

@Sorunome
Copy link
Contributor Author

For the record, /members is still working fine

@babolivier babolivier added A-Application-Service Related to AS support z-bug (Deprecated Label) z-p2 (Deprecated Label) labels Apr 30, 2020
@babolivier
Copy link
Contributor

babolivier commented May 1, 2020

Turns out this is the same cause as #7099 (custom events corrupting the users_in_room cache) and therefore will be fixed by #7376, thanks to @Sorunome for investigating and pointing it out.

richvdh added a commit that referenced this issue May 14, 2020
Fix a bug where the `get_joined_users` cache could be corrupted by custom
status events (or other state events with a state_key matching the user ID).

The bug was introduced by #2229, but has largely gone unnoticed since then.

Fixes #7099, #7373.
@richvdh richvdh closed this as completed May 14, 2020
phil-flex pushed a commit to phil-flex/synapse that referenced this issue Jun 16, 2020
)

Fix a bug where the `get_joined_users` cache could be corrupted by custom
status events (or other state events with a state_key matching the user ID).

The bug was introduced by matrix-org#2229, but has largely gone unnoticed since then.

Fixes matrix-org#7099, matrix-org#7373.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
A-Application-Service Related to AS support z-bug (Deprecated Label) z-p2 (Deprecated Label)
Projects
None yet
Development

No branches or pull requests

3 participants