Fix old ORG_CHANNEL rooms with no `groupId` not importing
Fix old ORG_CHANNEL
rooms with no groupId
not importing. These should have been picked way back when we migrated to groupId
so we would never run into a room like this but I guess it was never caught. Let's just deal with it.
Follow-up to !2313 (merged)
Part of #2609 (closed)
The import script was running into the following error:
$ matrix__bridge__applicationServicePort=9001 NODE_ENV=prod ./scripts/utils/gitter-to-matrix-historical-import-one-room.js --uri foo/bar
17 Jan 08:33:48 - opening socket: ws://cube.prod.gitter:1080/1.0/event/put
2023-01-17T08:33:49.898Z - info: Setting up Matrix bridge
2023-01-17T08:33:49.915Z - info: Matrix bridge listening on port 9001
2023-01-17T08:33:49.915Z - info: Ensuring profile info is up-to-date for the Matrix bridge user mxid=@gitter-badger:gitter.im
2023-01-17T08:33:50.011Z - info: Starting import script for foo/bar (57580f83c2f0db084a1cca60) --> matrixHistoricalRoomId=!xxx:gitter.im (live matrixRoomId=!xxx:gitter.im)
MatrixHttpClient (REQ-1) { errcode: 'M_USER_IN_USE', error: 'User ID already taken.' }
2023-01-17T08:33:50.245Z - error: Error occurred while backfilling events for opts.uri=foo/bar gitterRoomId=57580f83c2f0db084a1cca60: AssertionError [ERR_ASSERTION]: groupId=undefined unexpectedly does not exist for gitterRoomId=57580f83c2f0db084a1cca60
at MatrixUtils.ensureCorrectRoomState (./modules/matrix-bridge/lib/matrix-utils.js:367:5)
at async MatrixUtils.ensureCorrectHistoricalMatrixRoomStateAfterImport (./modules/matrix-bridge/lib/matrix-utils.js:536:7)
at async gitterToMatrixHistoricalImport (./modules/matrix-bridge/lib/gitter-to-matrix-historical-import.js:616:3)
at async exec (./scripts/utils/gitter-to-matrix-historical-import-one-room.js:50:3)
2023-01-17T08:33:50.246Z - warn: Waiting for this ongoing message send request to finish and bridged information stored...
redis handler failed during shutdown: TypeError: Cannot read property 'activeMasterClient' of undefined
Testing strategy
$ mongo gitter
> db.troupes.insert({
"githubType" : "ORG",
"userCount" : 9,
"security" : null,
"githubId" : 5990364,
"uri" : "gitterhq-legacy-test-org-channel",
"lcOwner" : "gitterhq-legacy-test-org-channel",
"lcUri" : "gitterhq-legacy-test-org-channel",
"__v" : 0,
"sd" : {
"type" : "GH_ORG",
"members" : "GH_ORG_MEMBER",
"admins" : "GH_ORG_MEMBER",
"public" : false,
"linkPath" : "gitterhq",
"externalId" : 5990364
}
});
> db.troupes.insert({
"githubType" : "ORG_CHANNEL",
"lcUri" : "gitterhq-legacy-test-org-channel/no-group-id",
"userCount" : 0,
"ownerUserId" : null,
"parentId" : db.troupes.findOne({ lcUri: "gitterhq-legacy-test-org-channel" })._id,
"security" : "PUBLIC",
"uri" : "gitterhq-legacy-test-org-channel/no-group-id",
"lcOwner" : "gitterhq-legacy-test-org-channel",
"bans" : [ ],
"oneToOneUsers" : [ ],
"providers" : [ ],
"renamedLcUris" : [ ],
"status" : "ACTIVE",
"tags" : [ ],
"sd" : {
"type" : "GH_ORG",
"members" : "INVITE",
"admins" : "GH_ORG_MEMBER",
"public" : false,
"linkPath" : "gitterhq",
"externalId" : 5990364
}
});
set DEBUG=gitter:scripts:*,gitter:app:matrix-bridge:gitter-to-matrix-historical-import,gitter:scripts-debug:events-imported&&set matrix__bridge__applicationServicePort=9001&&node ./scripts/utils/gitter-to-matrix-historical-import-one-room.js --uri gitterhq-legacy-test-org-channel/no-group-id
Edited by Eric Eastwood