{"record":{"id":"f2bfa77e4dae72c0","repo":"RocketChat/Rocket.Chat","slug":"invalid-livechat-config","errorCode":"invalid-livechat-config","errorMessage":"invalid-livechat-config","messagePattern":"invalid-livechat-config","errorType":"exception","errorClass":"Error","httpStatus":400,"severity":"warning","filePath":"apps/meteor/server/api/v1/omnichannel/room.ts","lineNumber":261,"sourceCode":"\t'livechat/room.survey',\n\t{ validateParams: isPOSTLivechatRoomSurveyParams },\n\t{\n\t\tasync post() {\n\t\t\tconst { rid, token, data } = this.bodyParams;\n\n\t\t\tconst visitor = await findGuest(token);\n\t\t\tif (!visitor) {\n\t\t\t\tthrow new Error('invalid-token');\n\t\t\t}\n\n\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 });","sourceCodeStart":243,"sourceCodeEnd":279,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/server/api/v1/omnichannel/room.ts#L243-L279","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check if settings() in your codebase returns survey with items and values arrays — restore them if missing.","If the survey feature was intentionally disabled, do not call the room.survey endpoint.","Verify no callback or middleware is stripping the survey property from the config response."],"exampleFix":"// before — settings() returns no survey\nconst config = await settings();\n// config.survey is undefined\n\n// after — ensure survey is populated in the settings function\nsurvey: {\n  items: ['satisfaction', 'agentKnowledge', 'agentResposiveness', 'agentFriendliness'],\n  values: ['1', '2', '3', '4', '5'],\n},","handlingStrategy":"validation","validationCode":"// Check that survey config is populated before submitting\nconst config = await settings();\nif (!config.survey?.items || !config.survey.values) {\n  throw new Error('Survey not configured — contact admin to enable survey settings');\n}","typeGuard":"function hasSurveyConfig(config: Record<string, any>): config is { survey: { items: string[]; values: string[] } } {\n  return (\n    config.survey != null &&\n    Array.isArray(config.survey.items) &&\n    config.survey.items.length > 0 &&\n    Array.isArray(config.survey.values) &&\n    config.survey.values.length > 0\n  );\n}","tryCatchPattern":"try {\n  await api.post('/livechat/room.survey', { rid, token, data });\n} catch (err) {\n  if (err.message === 'invalid-livechat-config') {\n    // survey feature not configured — inform admin or skip survey\n    console.log('Survey configuration missing — skipping survey submission');\n  }\n}","preventionTips":["Verify the settings() function returns a populated survey section in custom forks.","Do not call the room.survey endpoint if the survey feature is disabled.","Check for no callback or middleware stripping the survey property from the config response."],"tags":["omnichannel","survey","configuration","settings","defensive-check"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}