{"record":{"id":"b13d81a82793f680","repo":"RocketChat/Rocket.Chat","slug":"invalid-data","errorCode":"invalid-data","errorMessage":"invalid-data","messagePattern":"invalid-data","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"error","filePath":"apps/meteor/server/api/v1/omnichannel/room.ts","lineNumber":272,"sourceCode":"\t\t\tconst room = await findRoom(token, rid);\n\t\t\tif (!room) {\n\t\t\t\tthrow new Error('invalid-room');\n\t\t\t}\n\n\t\t\tconst config = await settings();\n\t\t\tif (!config.survey?.items || !config.survey.values) {\n\t\t\t\tthrow new Error('invalid-livechat-config');\n\t\t\t}\n\n\t\t\tconst updateData: { [k: string]: string } = {};\n\t\t\tfor (const item of data) {\n\t\t\t\tif ((config.survey.items.includes(item.name) && config.survey.values.includes(item.value)) || item.name === 'additionalFeedback') {\n\t\t\t\t\tupdateData[item.name] = item.value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (Object.keys(updateData).length === 0) {\n\t\t\t\tthrow new Error('invalid-data');\n\t\t\t}\n\n\t\t\tif (!(await LivechatRooms.updateSurveyFeedbackById(room._id, updateData))) {\n\t\t\t\treturn API.v1.failure();\n\t\t\t}\n\n\t\t\treturn API.v1.success({ rid, data: updateData });\n\t\t},\n\t},\n);\n\nAPI.v1.addRoute(\n\t'livechat/room.forward',\n\t{ authRequired: true, permissionsRequired: ['view-l-room', 'transfer-livechat-guest'], validateParams: isLiveChatRoomForwardProps },\n\t{\n\t\tasync post() {\n\t\t\tconst transferData = this.bodyParams as typeof this.bodyParams & {\n\t\t\t\ttransferredBy: TransferByData;","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/omnichannel/room.ts#L254-L290","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure submitted item.name values match exactly: 'satisfaction', 'agentKnowledge', 'agentResposiveness' (note the typo — no 'n' before 'iveness'), 'agentFriendliness', or 'additionalFeedback'.","Ensure submitted item.value is a string in ['1','2','3','4','5'] for the four rating items.","Include at least one valid item in the data array."],"exampleFix":"// before — wrong field names and numeric values\n{\n  rid: 'abc',\n  token: 'xyz',\n  data: [\n    { name: 'agentResponsiveness', value: 5 },  // wrong name + numeric value\n  ]\n}\n// throws 'invalid-data'\n\n// after — exact field name (note typo) and string value\n{\n  rid: 'abc',\n  token: 'xyz',\n  data: [\n    { name: 'agentResposiveness', value: '5' },\n  ]\n}","handlingStrategy":"validation","validationCode":"// Validate survey items against allowed names and values before submitting\nconst ALLOWED_ITEMS = ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness', 'additionalFeedback'];\nconst ALLOWED_VALUES = ['1', '2', '3', '4', '5'];\n\nconst filtered = data.filter(item => {\n  if (item.name === 'additionalFeedback') return true;\n  return ALLOWED_ITEMS.includes(item.name) && ALLOWED_VALUES.includes(String(item.value));\n});\nif (filtered.length === 0) {\n  throw new Error('No valid survey items — check field names and values');\n}","typeGuard":"function isValidSurveyItem(item: { name: string; value: string }): boolean {\n  const ALLOWED_ITEMS = ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness', 'additionalFeedback'];\n  const ALLOWED_VALUES = ['1', '2', '3', '4', '5'];\n  if (item.name === 'additionalFeedback') return true;\n  return ALLOWED_ITEMS.includes(item.name) && ALLOWED_VALUES.includes(String(item.value));\n}","tryCatchPattern":"try {\n  await api.post('/livechat/room.survey', { rid, token, data });\n} catch (err) {\n  if (err.message === 'invalid-data') {\n    // fix item names/values and retry — note the server typo 'agentResposiveness'\n    data = data.map(d => ({ ...d, value: String(d.value) }));\n    await api.post('/livechat/room.survey', { rid, token, data });\n  }\n}","preventionTips":["Match server field names exactly — note the typo 'agentResposiveness' (no 'n' before 'iveness').","Send survey values as strings ('1'-'5'), not numbers (5).","Include at least one valid rating item in the data array.","Validate against the config.survey.items and config.survey.values from the settings endpoint before submitting."],"tags":["omnichannel","survey","validation","data-format","room"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}