matrix-org / matrix-appservice-irc

Node.js IRC bridge for Matrix
Apache License 2.0
465 stars 151 forks source link

MatrixHandler::handleAdminRoomInvite exception handler is throwing due to undefined properties #1346

Open andir opened 3 years ago

andir commented 3 years ago

Describe the bug I believe the error logging code in the MatrixHandler::handleAdminRoomInvite function is actually wrong in this line: https://github.com/matrix-org/matrix-appservice-irc/blob/df0d2c8a23e01513a829c0d8a1ac411de32b6c92/src/bridge/MatrixHandler.ts#L139

During testing on a hackint test instance of the bridge we did observe the above mentioned line throw because the attribute data doesn't exist on the exception that was caught. Unfortunately I can't tell which exception from the logs we have.

1438362-May 27 01:30:45 matrix matrix-appservice-irc[13299]: 2021-05-27 01:30:45 ERROR:main TypeError: Cannot read property 'error' of undefined
1438363:May 27 01:30:45 matrix matrix-appservice-irc[13299]:     at MatrixHandler.handleAdminRoomInvite (/nix/store/5cb5prvqiq1zzp3kp7s3f1iaqr1xg59i-node_matrix-appservice-irc-0.26.0/lib/node_modules/matrix-appservice-irc/lib/bridge/MatrixHandler.js:69:93)
1438364-May 27 01:30:45 matrix matrix-appservice-irc[13299]:     at runMicrotasks (<anonymous>)
1438365-May 27 01:30:45 matrix matrix-appservice-irc[13299]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)

To Reproduce Steps to reproduce the behavior:

  1. We had some intermediary configuration that I can't recall, sorry
  2. Tried to join an IRC channel via the matrix bridge (from the matrix side)
  3. The AppService would throw the above exception when trying to invite you.

Expected behavior

The error message (including the exception body?) should be logged and not cause another exception.

andir commented 3 years ago

Apparently related to https://github.com/matrix-org/matrix-appservice-irc/issues/1270 as that contains similar output from other users.

Half-Shot commented 3 years ago

It looks bad, but it's not the same as #1270. I've posted a solution to that one.

bugz8unny69 commented 2 years ago

It's Jan 2022, there's no fix? I dunno but this seems trivial to fix no? For those who come here, wondering what to do:

--- lib/bridge/MatrixHandler.js.original   2022-01-08 09:34:16.830231247 -0500
+++ lib/bridge/MatrixHandler.js    2022-01-08 09:23:30.582026773 -0500
@@ -78,7 +78,8 @@
             }
         }
         catch (err) {
-            req.log.debug(`Not a plumbed room: Error retrieving m.room.plumbing (${err.data.error})`);
+            //req.log.debug(`Not a plumbed room: Error retrieving m.room.plumbing (${err.data.error})`);
+            req.log.debug(`Not a plumbed room: Error retrieving m.room.plumbing (FIXME)`);
         }
         // clobber any previous admin room ID
         await this.ircBridge.getStore().storeAdminRoom(mxRoom, inviter.userId);

NOTE: I want to point out, joining a bridge room, the bot invites me fine. It's when I leave the DM and DM the bot back, does this problem occur. Also, if for some reason (like #1270) profile is missing, I get the same exception.