matrix-org / matrix-appservice-slack

A Matrix <--> Slack bridge
Apache License 2.0
276 stars 72 forks source link

Slackbot (in matrix) bot doesn't accept invites #608

Open tuncbkose opened 3 years ago

tuncbkose commented 3 years ago

Describe the bug Slackbot doesn't accept invites.

Expected behavior Slackbot accepts the invite.

Jul-29 04:23:22.918 INFO Main Enabled RTM
Jul-29 04:23:22.939 INFO Main Loading databases
Jul-29 04:23:23.003 INFO PgDatastore Database schema is at version v12
Jul-29 04:23:23.008 INFO SlackHookHandler Slack-side listening on port 9898 over http
Jul-29 04:23:23.014 INFO bridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) Body: 
Jul-29 04:23:23.027 INFO bridge [-] GET http://localhost:8008/_matrix/client/r0/joined_rooms (AS) HTTP 200 "{\"joined_rooms\":[]}"
Jul-29 04:23:23.028 INFO Main Ensuring the bridge bot is registered
Jul-29 04:23:23.029 INFO bridge [-] POST http://localhost:8008/_matrix/client/r0/register (AS) Body: "{\"type\":\"m.login.application_service\",\"username\":\"slackbot\"}"
Jul-29 04:23:23.043 ERROR bridge [-] POST http://localhost:8008/_matrix/client/r0/register (AS) HTTP 400 Error: "{\"errcode\":\"M_USER_IN_USE\",\"error\":\"User ID already taken.\"}"
Jul-29 04:23:23.045 INFO bridge [-] GET http://localhost:8008/_matrix/client/r0/profile/%40slackbot%3Alocalhost (AS) Body: 
Jul-29 04:23:23.059 ERROR bridge [-] GET http://localhost:8008/_matrix/client/r0/profile/%40slackbot%3Alocalhost (AS) HTTP 502 Error: "{\"errcode\":\"M_UNKNOWN\",\"error\":\"Failed to fetch profile\"}"
Jul-29 04:23:23.060 WARN Main Failed to set bot profile on startup: M_UNKNOWN: Failed to fetch profile
Jul-29 04:23:23.060 WARN Main The bot is not in the admin room. You should invite the bot in order to control the bridge.
Jul-29 04:23:23.061 INFO Main Fetching teams
Jul-29 04:23:23.064 INFO Main Loaded 1 teams
Jul-29 04:23:23.065 INFO Main [0/1] Getting team client for Matrix Test Space
Jul-29 04:23:23.071 INFO SlackClientFactory Creating new team client for *********
Jul-29 04:23:23.789 INFO Main Starting RTM for **********
Jul-29 04:23:24.075 INFO SlackRTMHandler Connected RTM client for  {
  id: '**********',
  name: '*******',
  domain: '********'
}
Jul-29 04:23:24.076 INFO Main Started RTM for ********
Jul-29 04:23:24.076 INFO Main Finished loading all team clients
Jul-29 04:23:24.077 INFO Main Found 1 room entries in store
Jul-29 04:23:24.078 INFO Main [1/1] Loading room entry !********:domain.tld
Jul-29 04:23:24.078 WARN Main !*******:domain.tld marked as inactive, bot is not joined to room
Jul-29 04:23:24.081 INFO Main Bridge initialised
Jul-29 04:23:24.081 INFO app Matrix-side listening on port ***
Jul-29 04:25:39.289 INFO bridge ***.***.***.*** - - [29/Jul/2021:04:25:39 +0000] "PUT /transactions/21?access_token=<REDACTED> HTTP/1.1" 200 2 "-" "Synapse/1.38.1"

Jul-29 04:25:39.291 INFO Main Handled $9_44GTGG4N4Kp87DVCQwzmn7VNRY6W7tDlFNQ2omjTQ (!*****:domaintld)

The last info message is in response to invitation/disinvitation so the app is working. Thinking that this and "User ID already taken" are related, I tried editing slack-registration.yaml to change the name from slackbot to something else but it gave a different error:

Jul-29 04:23:06.886 ERROR bridge [-] POST http://localhost:8008/_matrix/client/r0/register (AS) HTTP 400 Error: "{\"errcode\":\"M_EXCLUSIVE\",\"error\":\"Invalid user localpart for this application service.\"}"

Edit: This is with the latest release.

quinm0 commented 3 years ago

I think I'm also seeing this issue

Half-Shot commented 3 years ago

It may be worth checking to see if your user regex in your registration file matches https://github.com/matrix-org/matrix-appservice-slack/blob/develop/config/config.sample.yaml#L30, as that would cause the error linked.

The logs also indicate that you are looking for @slackbot:localhost which doesn't map to Loading room entry !********:domain.tld, so your domain in your config might be wrong.

manning-ncsa commented 2 years ago

I was seeing similar behavior, and I finally figured out the problem. In my case it was because I had specified the homeserver.server_name parameter as matrix.example.com, when what works is instead to set this to the domain associated with the slackbot Matrix ID, which is example.com (assuming you have configured your homeserver in the typical way such that Matrix IDs do not include the matrix. prefix people typically prepend to their homeserver URL). The similar error messages I see about the slackbot username being already taken and messages about failing to load the user profile do not seem to prevent the bridge from working.

jaller94 commented 2 years ago

Not sure what labels to give to this as it seem to be an issue with the configuration.

Half-Shot commented 2 years ago

I'd call it a documentation bug, given this could probably be solved with more specific language