RocketChat/Rocket.Chat · error · Error

invalid-data

invalid-data

Error message

invalid-data

What it means

Thrown in the POST handler of 'livechat/room.survey' (room.ts:264-273) when the filtered updateData object is empty. The handler iterates over the submitted data items and only keeps those whose name is in config.survey.items AND value is in config.survey.values, plus the special 'additionalFeedback' field. If none of the submitted items pass this filter, updateData remains empty and the error fires.

Source

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

			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 });
		},
	},
);

API.v1.addRoute(
	'livechat/room.forward',
	{ authRequired: true, permissionsRequired: ['view-l-room', 'transfer-livechat-guest'], validateParams: isLiveChatRoomForwardProps },
	{
		async post() {
			const transferData = this.bodyParams as typeof this.bodyParams & {
				transferredBy: TransferByData;

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Ensure submitted item.name values match exactly: 'satisfaction', 'agentKnowledge', 'agentResposiveness' (note the typo — no 'n' before 'iveness'), 'agentFriendliness', or 'additionalFeedback'.
  2. Ensure submitted item.value is a string in ['1','2','3','4','5'] for the four rating items.
  3. Include at least one valid item in the data array.

Example fix

// before — wrong field names and numeric values
{
  rid: 'abc',
  token: 'xyz',
  data: [
    { name: 'agentResponsiveness', value: 5 },  // wrong name + numeric value
  ]
}
// throws 'invalid-data'

// after — exact field name (note typo) and string value
{
  rid: 'abc',
  token: 'xyz',
  data: [
    { name: 'agentResposiveness', value: '5' },
  ]
}
Defensive patterns

Strategy: validation

Validate before calling

// Validate survey items against allowed names and values before submitting
const ALLOWED_ITEMS = ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness', 'additionalFeedback'];
const ALLOWED_VALUES = ['1', '2', '3', '4', '5'];

const filtered = data.filter(item => {
  if (item.name === 'additionalFeedback') return true;
  return ALLOWED_ITEMS.includes(item.name) && ALLOWED_VALUES.includes(String(item.value));
});
if (filtered.length === 0) {
  throw new Error('No valid survey items — check field names and values');
}

Type guard

function isValidSurveyItem(item: { name: string; value: string }): boolean {
  const ALLOWED_ITEMS = ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness', 'additionalFeedback'];
  const ALLOWED_VALUES = ['1', '2', '3', '4', '5'];
  if (item.name === 'additionalFeedback') return true;
  return ALLOWED_ITEMS.includes(item.name) && ALLOWED_VALUES.includes(String(item.value));
}

Try / catch

try {
  await api.post('/livechat/room.survey', { rid, token, data });
} catch (err) {
  if (err.message === 'invalid-data') {
    // fix item names/values and retry — note the server typo 'agentResposiveness'
    data = data.map(d => ({ ...d, value: String(d.value) }));
    await api.post('/livechat/room.survey', { rid, token, data });
  }
}

Prevention

When it happens

Trigger: Calling POST /api/v1/livechat/room.survey where none of the submitted survey items match the allowed item names or value ranges. Allowed item names are ['satisfaction','agentKnowledge','agentResposiveness','agentFriendliness'] with values ['1'-'5'], plus 'additionalFeedback'. Submitting items with unrecognized names or out-of-range values triggers this.

Common situations: Client sends survey item names that don't match the server's expected keys (e.g. 'agentResponsiveness' vs the server's typo 'agentResposiveness'); values sent as integers instead of strings (e.g. 5 instead of '5'); submitting only custom fields not in the allowed list; empty data array.

Related errors


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