RocketChat/Rocket.Chat · error · MeteorError
error-invalid-room
error-invalid-room
Error message
Invalid room
What it means
Thrown by POST /api/v1/rooms.delete when Rooms.findOneById(roomId) returns null: the roomId in the body matches no room, typically because it was already deleted or is malformed. The error carries details.method 'eraseRoom' identifying the underlying operation. Deletion is not idempotent; a second delete of the same room fails here.
Solutions
- Confirm the room still exists with GET /api/v1/rooms.info?roomId=... before deleting
- Treat this error as success in idempotent delete flows ('already gone')
- Debounce or lock delete buttons and script steps to prevent double submission
- Validate the id length/format before sending (Rocket.Chat ids are 17-char alphanumeric)
Example fix
// before
await sdk.post('rooms.delete', { roomId: staleId }); // already deleted -> error-invalid-room
// after
try {
await sdk.get('rooms.info', { roomId: staleId });
} catch {
return; // room already gone, nothing to delete
}
await sdk.post('rooms.delete', { roomId: staleId }); Defensive patterns
Strategy: validation
Validate before calling
try { await sdk.get('rooms.info', { roomId }); } catch { throw new Error(`room '${roomId}' does not exist`); } Try / catch
try {
await sdk.post('rooms.delete', { roomId });
} catch (e: any) {
if (e?.response?.data?.errorType === 'error-invalid-room' && e?.response?.data?.details?.method === 'eraseRoom') {
return; // already deleted — idempotent success
}
throw e;
} Prevention
- Treat double-delete as success in retry logic
- Confirm existence before deleting when you need an audit decision point
- Guard delete actions against double-submission in UIs
When it happens
Trigger: POST rooms.delete with a roomId that was deleted in an earlier request (double-submit, retry after timeout, two admins racing); a copy-paste-mangled id; deleting from workspace A an id obtained from workspace B.
Common situations: Retry logic that re-sends deletion after a network timeout when the first attempt succeeded; cleanup scripts processing stale room lists; concurrent moderation actions; test teardown running twice.
Related errors
- error-cannot-delete-team-channel
- Custom_User_Status_Error_Invalid_User_Status
- error-action-not-allowed
- error-invalid-subscription
- error-invalid-subscription
AI-assisted analysis of RocketChat/Rocket.Chat@e4b8178b20 (2026-08-18).
Data as JSON: /api/errors/bc299a00fee43d4f.
Report an issue: GitHub.
Appendix: source
Thrown at apps/meteor/server/api/v1/rooms.ts:206
type: 'boolean',
enum: [true],
description: 'Indicates if the request was successful.',
},
},
required: ['success'],
additionalProperties: false,
}),
400: validateBadRequestErrorResponse,
401: validateUnauthorizedErrorResponse,
},
},
async function action() {
const { roomId } = this.bodyParams;
const room = await Rooms.findOneById(roomId);
if (!room) {
throw new MeteorError('error-invalid-room', 'Invalid room', {
method: 'eraseRoom',
});
}
if (room.teamMain) {
throw new Meteor.Error('error-cannot-delete-team-channel', 'Cannot delete a team channel', {
method: 'eraseRoom',
});
}
await eraseRoom(room, this.user);
return API.v1.success();
},
);
API.v1.get(
'rooms.get',View on GitHub (pinned to e4b8178b20)