RocketChat/Rocket.Chat · warning · Error

invalid-livechat-config

invalid-livechat-config

Error message

invalid-livechat-config

What it means

Thrown in the POST handler of 'livechat/room.survey' (room.ts:259-262) when the survey configuration is missing. The settings() function (from lib/livechat.ts) returns a config object; if config.survey is undefined, or config.survey.items is falsy, or config.survey.values is falsy, this error fires. In the default implementation, survey always includes hardcoded items and values arrays, so this fires only if settings() was overridden or customized.

Source

Thrown at apps/meteor/server/api/v1/omnichannel/room.ts:261

	'livechat/room.survey',
	{ validateParams: isPOSTLivechatRoomSurveyParams },
	{
		async post() {
			const { rid, token, data } = this.bodyParams;

			const visitor = await findGuest(token);
			if (!visitor) {
				throw new Error('invalid-token');
			}

			const room = await findRoom(token, rid);
			if (!room) {
				throw new Error('invalid-room');
			}

			const config = await settings();
			if (!config.survey?.items || !config.survey.values) {
				throw new Error('invalid-livechat-config');
			}

			const updateData: { [k: string]: string } = {};
			for (const item of data) {
				if ((config.survey.items.includes(item.name) && config.survey.values.includes(item.value)) || item.name === 'additionalFeedback') {
					updateData[item.name] = item.value;
				}
			}

			if (Object.keys(updateData).length === 0) {
				throw new Error('invalid-data');
			}

			if (!(await LivechatRooms.updateSurveyFeedbackById(room._id, updateData))) {
				return API.v1.failure();
			}

			return API.v1.success({ rid, data: updateData });

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Check if settings() in your codebase returns survey with items and values arrays — restore them if missing.
  2. If the survey feature was intentionally disabled, do not call the room.survey endpoint.
  3. Verify no callback or middleware is stripping the survey property from the config response.

Example fix

// before — settings() returns no survey
const config = await settings();
// config.survey is undefined

// after — ensure survey is populated in the settings function
survey: {
  items: ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness'],
  values: ['1', '2', '3', '4', '5'],
},
Defensive patterns

Strategy: validation

Validate before calling

// Check that survey config is populated before submitting
const config = await settings();
if (!config.survey?.items || !config.survey.values) {
  throw new Error('Survey not configured — contact admin to enable survey settings');
}

Type guard

function hasSurveyConfig(config: Record<string, any>): config is { survey: { items: string[]; values: string[] } } {
  return (
    config.survey != null &&
    Array.isArray(config.survey.items) &&
    config.survey.items.length > 0 &&
    Array.isArray(config.survey.values) &&
    config.survey.values.length > 0
  );
}

Try / catch

try {
  await api.post('/livechat/room.survey', { rid, token, data });
} catch (err) {
  if (err.message === 'invalid-livechat-config') {
    // survey feature not configured — inform admin or skip survey
    console.log('Survey configuration missing — skipping survey submission');
  }
}

Prevention

When it happens

Trigger: Calling POST /api/v1/livechat/room.survey when the settings() function returns a config object without a properly populated survey section. In the stock Rocket.Chat implementation, survey is hardcoded with items ['satisfaction','agentKnowledge','agentResposiveness','agentFriendliness'] and values ['1','2','3','4','5'], so this would only fire if a customization or fork modified the settings function.

Common situations: A fork or customization replaced the settings() function and omitted or renamed the survey section; a plugin hook modified the returned config object and stripped survey data; the survey feature was intentionally disabled by removing the config.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/f2bfa77e4dae72c0. Report an issue: GitHub.