{"record":{"id":"b13d81a82793f680","repo":"RocketChat/Rocket.Chat","slug":"invalid-data","errorCode":null,"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/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/api/v1/omnichannel/room.ts#L254-L290","documentation":"Thrown by POST /api/v1/livechat/room.survey when the request body's data array produces an empty updateData: every entry failed the filter (name must be a configured survey item AND value a configured survey value, or name must be exactly 'additionalFeedback'). The config was fine; the submitted answers matched nothing.","triggerScenarios":"Sending survey answers whose item names do not match config.survey.items (e.g. 'satisfaction' vs 'feedback'), whose values are outside config.survey.values (e.g. '6' on a 1–5 scale), sending an empty data array, or sending only unrecognized free-form keys.","commonSituations":"Custom survey UI hardcoded with item names/values that drifted from the admin-configured survey; client sending display labels instead of stored values; localizing the item names before submission.","solutions":["Fetch the definition first (GET livechat/config or the config embedded in the widget) and build the form from survey.items/survey.values","Map answers to exact configured names/values, and include additionalFeedback verbatim as the free-text key","Client-side: reject submission when every field is empty instead of posting an empty payload"],"exampleFix":"// before\npostSurvey(rid, token, [\n  { name: 'How satisfied were you?', value: 'very' }, // display name + label value\n]);\n\n// after\nconst { survey } = await getLivechatConfig();\npostSurvey(rid, token, [\n  { name: survey.items[0], value: survey.values[4] }, // exact configured name + value\n  { name: 'additionalFeedback', value: comment },\n]);","handlingStrategy":"validation","validationCode":"const { survey } = await getLivechatConfig();\nconst valid = data.filter((item) =>\n  (survey.items.includes(item.name) && survey.values.includes(item.value)) || item.name === 'additionalFeedback',\n);\nif (valid.length === 0) return warnUser('fill at least one field');\nawait postSurvey(rid, token, valid);","typeGuard":"function isSurveyItemValid(item, survey) {\n  return (survey.items.includes(item.name) && survey.values.includes(item.value)) || item.name === 'additionalFeedback';\n}","tryCatchPattern":"try { await postSurvey(rid, token, data); } catch (e) { if (e.message === 'invalid-data') { rebuildFormFromConfig(); return; } throw e; }","preventionTips":["Build the survey form from survey.items/survey.values returned by livechat/config","Never localize or rename item names before submission","Require at least one answered field client-side before posting"],"tags":["omnichannel","livechat","survey","request-validation","rest-api"],"backgroundTag":"request-validation-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}