{"record":{"id":"bc299a00fee43d4f","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-bc299a","errorCode":"error-invalid-room","errorMessage":"Invalid room","messagePattern":"Invalid room","errorType":"exception","errorClass":"MeteorError","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/api/v1/rooms.ts","lineNumber":202,"sourceCode":"\t\t\t\t\t\ttype: 'boolean',\n\t\t\t\t\t\tenum: [true],\n\t\t\t\t\t\tdescription: 'Indicates if the request was successful.',\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\trequired: ['success'],\n\t\t\t\tadditionalProperties: false,\n\t\t\t}),\n\t\t\t400: validateBadRequestErrorResponse,\n\t\t\t401: validateUnauthorizedErrorResponse,\n\t\t},\n\t},\n\tasync function action() {\n\t\tconst { roomId } = this.bodyParams;\n\n\t\tconst room = await Rooms.findOneById(roomId);\n\n\t\tif (!room) {\n\t\t\tthrow new MeteorError('error-invalid-room', 'Invalid room', {\n\t\t\t\tmethod: 'eraseRoom',\n\t\t\t});\n\t\t}\n\n\t\tif (room.teamMain) {\n\t\t\tthrow new Meteor.Error('error-cannot-delete-team-channel', 'Cannot delete a team channel', {\n\t\t\t\tmethod: 'eraseRoom',\n\t\t\t});\n\t\t}\n\n\t\tawait eraseRoom(room, this.user);\n\n\t\treturn API.v1.success();\n\t},\n);\n\nAPI.v1.get(\n\t'rooms.get',","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/rooms.ts#L184-L220","documentation":"Thrown by POST rooms.delete when Rooms.findOneById(roomId) returns null. The endpoint is auth-required, takes a roomId in the body (validated, required), and uses the MeteorError class (not Meteor.Error) with method context 'eraseRoom'. Returns a structured error body keyed on 'error-invalid-room'.","triggerScenarios":"POST /api/v1/rooms.delete with a roomId that does not match any room (typo, already deleted, id from another workspace).","commonSituations":"Client retries a delete after the room was already removed; UI lists a stale room; roomId confused with a message or thread id.","solutions":["Verify the room exists (rooms.info) before deleting.","Treat 'error-invalid-room' as success for idempotent delete workflows (room already gone).","Ensure you pass the room _id in the roomId body field as defined by the schema."],"exampleFix":"// before\nawait fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) });\n\n// after - idempotent delete\ntry {\n  await fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) });\n} catch (e) {\n  if (e.error === 'error-invalid-room') return; // already deleted\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Confirm the room exists before deleting\nconst res = await fetch(`/api/v1/rooms.info?roomId=${encodeURIComponent(roomId)}`);\nif (res.status === 404) return; // already gone\nawait fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) });","typeGuard":null,"tryCatchPattern":"try {\n  await fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) }).then(r => r.json());\n} catch (e) {\n  if (e.error === 'error-invalid-room') return; // idempotent: already deleted\n  throw e;\n}","preventionTips":["For idempotent delete flows, swallow error-invalid-room.","Pass the room _id (not message/thread id) in roomId."],"tags":["rooms","rest-api","not-found","delete","validation"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}