RocketChat/Rocket.Chat · error · MeteorError
error-invalid-room
error-invalid-room
Error message
Invalid room
What it means
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'.
Source
Thrown at apps/meteor/server/api/v1/rooms.ts:202
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 f9d3ec372b)
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.
Example fix
// before
await fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) });
// after - idempotent delete
try {
await fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) });
} catch (e) {
if (e.error === 'error-invalid-room') return; // already deleted
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Confirm the room exists before deleting
const res = await fetch(`/api/v1/rooms.info?roomId=${encodeURIComponent(roomId)}`);
if (res.status === 404) return; // already gone
await fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) }); Try / catch
try {
await fetch('/api/v1/rooms.delete', { method:'POST', body: JSON.stringify({ roomId }) }).then(r => r.json());
} catch (e) {
if (e.error === 'error-invalid-room') return; // idempotent: already deleted
throw e;
} Prevention
- For idempotent delete flows, swallow error-invalid-room.
- Pass the room _id (not message/thread id) in roomId.
When it happens
Trigger: POST /api/v1/rooms.delete with a roomId that does not match any room (typo, already deleted, id from another workspace).
Common situations: Client retries a delete after the room was already removed; UI lists a stale room; roomId confused with a message or thread id.
Related errors
- error-room-not-found
- error-room-param-not-provided
- error-room-not-found
- error-invalid-roleId
- error-invalid-user
AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12).
Data as JSON: /api/errors/bc299a00fee43d4f.
Report an issue: GitHub.