{"record":{"id":"0fce443d82b17f47","repo":"RocketChat/Rocket.Chat","slug":"invalid-room-0fce44","errorCode":"invalid-room","errorMessage":"Invalid room","messagePattern":"Invalid room","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/rooms/settings/saveRoomDescription.ts","lineNumber":10,"sourceCode":"import { Message } from '@rocket.chat/core-services';\nimport type { IUser } from '@rocket.chat/core-typings';\nimport { Rooms } from '@rocket.chat/models';\nimport { Match } from 'meteor/check';\nimport { Meteor } from 'meteor/meteor';\nimport type { UpdateResult } from 'mongodb';\n\nexport const saveRoomDescription = async function (rid: string, roomDescription: string, user: IUser): Promise<UpdateResult> {\n\tif (!Match.test(rid, String)) {\n\t\tthrow new Meteor.Error('invalid-room', 'Invalid room', {\n\t\t\tfunction: 'RocketChat.saveRoomDescription',\n\t\t});\n\t}\n\n\tconst update = await Rooms.setDescriptionById(rid, roomDescription);\n\tawait Message.saveSystemMessage('room_changed_description', rid, roomDescription, user);\n\treturn update;\n};\n","sourceCodeStart":1,"sourceCodeEnd":19,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/rooms/settings/saveRoomDescription.ts#L1-L19","documentation":"Thrown by saveRoomDescription when Match.test(rid, String) fails (saveRoomDescription.ts:10). Pure argument-type gate before Rooms.setDescriptionById; no system message is written when it throws. Code 'invalid-room', details { function: 'RocketChat.saveRoomDescription' }.","triggerScenarios":"saveRoomDescription(undefined, text, user) from an unbound form field; passing room object or ObjectId; renamed variable (rid vs roomId) missing one call site.","commonSituations":"Method/REST wrappers forwarding user input without checks; UI components passing the whole room record; test helpers with placeholder ids.","solutions":["Pass room._id as a string","Type-check at the API boundary before calling","Search for the call site and confirm which variable is actually passed","Add a unit test asserting the guard fires for non-string input so regressions surface clearly"],"exampleFix":"// before\nawait saveRoomDescription(room, description, user);\n\n// after\nawait saveRoomDescription(room._id, description, user);","handlingStrategy":"type-guard","validationCode":"if (typeof rid !== 'string' || rid.length === 0) {\n\tthrow new Meteor.Error('invalid-room', 'Invalid room', { function: 'RocketChat.saveRoomDescription' });\n}\nawait saveRoomDescription(rid, description, user);","typeGuard":"const isRoomId = (v: unknown): v is string => typeof v === 'string' && v.length > 0;","tryCatchPattern":null,"preventionTips":["Pass room._id; never the room record or an ObjectId","Centralize the string-rid check in a shared settings-handler helper","Cover the guard in unit tests for early failure clarity"],"tags":["room-settings","argument-validation","meteor-check","description"],"backgroundTag":"invalid-argument-value","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}