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

  1. Confirm the room still exists with GET /api/v1/rooms.info?roomId=... before deleting
  2. Treat this error as success in idempotent delete flows ('already gone')
  3. Debounce or lock delete buttons and script steps to prevent double submission
  4. 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

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


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)