the-draupnir-project / Draupnir

A Matrix moderation bot
https://the-draupnir-project.github.io/draupnir-documentation/
Academic Free License v3.0
68 stars 13 forks source link

M_NOT_FOUND, Account data not found #427

Closed erebion closed 1 month ago

erebion commented 1 month ago

Hello,

starting the bot gives me the following output:

Creating Web APIs
Starting web server
Fri, 17 May 2024 11:46:30 GMT [WARN] [ProtectedRoomsConfig] Couldn't find any explicitly protected rooms from Mjolnir's account data, assuming first start. MatrixError: Error during MatrixClient request GET /_matrix/client/v3/user/%40bot%3Aexample.com/account_data/org.matrix.mjolnir.protected_rooms: 404 Not Found -- {"errcode":"M_NOT_FOUND","error":"Account data not found"}
    at /mjolnir/utils.js:278:21
    at result (/mjolnir/utils.js:397:25)
    at new Promise (<anonymous>)
    at /mjolnir/utils.js:396:40
    at respIsBuffer (/node_modules/matrix-bot-sdk/lib/http.js:66:38)
    at new Promise (<anonymous>)
    at doHttpRequest (/node_modules/matrix-bot-sdk/lib/http.js:65:41)
    at MatrixClient.doRequest (/node_modules/matrix-bot-sdk/lib/MatrixClient.js:1785:41)
    at descriptor.value (/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:53)
    at MatrixClient.getAccountData (/node_modules/matrix-bot-sdk/lib/MatrixClient.js:280:21) {
  body: { errcode: 'M_NOT_FOUND', error: 'Account data not found' },
  statusCode: 404,
  errcode: 'M_NOT_FOUND',
  error: 'Account data not found',
  retryAfterMs: undefined
}

Looking at the log of the Reverse Proxy, I see something like this:

172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/joined_rooms HTTP/1.1" 200 67 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/directory/room/%23bot%3Astaging.example.com HTTP/1.1" 200 90 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/account/whoami HTTP/1.1" 200 66 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/profile/%40bot%3Aexample.com HTTP/1.1" 200 59 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/m.room.canonical_alias/ HTTP/1.1" 200 47 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "PUT /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/send/m.room.message/1715946390718__inc1 HTTP/1.1" 200 70 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/joined_rooms HTTP/1.1" 200 67 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/user/%40bot%3Aexample.com/account_data/org.matrix.mjolnir.protected_rooms HTTP/1.1" 404 69 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/user/%40bot%3Aexample.com/account_data/org.matrix.mjolnir.watched_lists HTTP/1.1" 404 69 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/joined_rooms HTTP/1.1" 200 67 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/user/%40bot%3Aexample.com/account_data/org.matrix.mjolnir.enabled_protections HTTP/1.1" 404 69 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/FirstMessageIsImageProtection HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/BanPropagationProtection HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/BasicFloodingProtection HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/WordList HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/MessageIsVoiceProtection HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/MessageIsMediaProtection HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/TrustedReporters HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/DetectFederationLag HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/org.matrix.mjolnir.setting/JoinWaveShortCircuit HTTP/1.1" 404 63 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/m.room.canonical_alias/ HTTP/1.1" 200 47 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "PUT /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/send/m.room.message/1715946390856__inc2 HTTP/1.1" 200 70 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "PUT /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/send/m.room.message/1715946390898__inc3 HTTP/1.1" 200 70 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/user/%40bot%3Aexample.com/account_data/m.direct HTTP/1.1" 404 69 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/joined_rooms HTTP/1.1" 200 67 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/sync?full_state=false&timeout=30000&since=s25582_6968605_210_17147_1452_4_3659_1214973_0_8 HTTP/1.1" 200 904 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/m.room.canonical_alias/ HTTP/1.1" 200 47 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:30 +0200] "GET /_matrix/client/v3/sync?full_state=false&timeout=30000&since=s25583_6968608_210_17147_1452_4_3659_1214973_0_8 HTTP/1.1" 200 1195 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "PUT /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/send/m.room.message/1715946390979__inc4 HTTP/1.1" 200 70 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "GET /_matrix/client/v3/sync?full_state=false&timeout=30000&since=s25585_6968608_210_17147_1452_4_3659_1214973_0_8 HTTP/1.1" 200 829 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "PUT /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/send/m.room.message/1715946391031__inc5 HTTP/1.1" 200 70 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "GET /_matrix/client/v3/sync?full_state=false&timeout=30000&since=s25586_6968608_210_17147_1452_4_3659_1214973_0_8 HTTP/1.1" 200 892 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "GET /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/state/m.room.canonical_alias/ HTTP/1.1" 200 47 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "PUT /_matrix/client/v3/rooms/!longroomid%3Astaging.example.com/send/m.room.message/1715946391134__inc6 HTTP/1.1" 200 70 "-" "-"
172.17.0.2 - - [17/May/2024:13:46:31 +0200] "GET /_matrix/client/v3/sync?full_state=false&timeout=30000&since=s25587_6968608_210_17147_1452_4_3659_1214973_0_8 HTTP/1.1" 200 875 "-" "-"

However, if I ask the bot to output its status, it prints out the names of the lists it is subscribed to.

Everything seems to work.

Now, this leads to some confusion:

It clearly finds data, otherwise it would not know what lists to use on what rooms, right?

Gnuxie commented 1 month ago

Hi there, the bot is warning that there are no protected rooms configured with the !draupnir rooms add command. Unless you have set protectAllJoinedRooms: true in the config file, then this means that bans will not be synchronised and protections are not being run in any rooms. However, if protectAllJoinedRooms: true is set, then you do not need to worry. You can confirm what rooms are being protected by Draupnir by using the !draupnir rooms list command. You should only worry if this list is empty.

Gnuxie commented 1 month ago

To be clear, protected rooms are distinct from subscribed/watched lists. The protected rooms are the rooms that you want your Draupnir to ban users from. Whereas the policy lists (subscribed/watched lists) are where your Draupnir will source policies from that will tell Draupnir who to ban etc.

erebion commented 1 month ago

Oh, I see. That message certainly is confusing. Thanks :)

Gnuxie commented 1 month ago

Hey, I've opened a follow up issue here that should cover the confusion https://github.com/the-draupnir-project/Draupnir/issues/435. We're also currently reworking the setup documentation https://github.com/the-draupnir-project/planning/issues/16, so keep an eye out for that!

Gnuxie commented 1 month ago

Oh, and do let me know if you have any other concerns!