{"record":{"id":"20613b91968e51e3","repo":"RocketChat/Rocket.Chat","slug":"invalid-payload-20613b","errorCode":null,"errorMessage":"Invalid payload","messagePattern":"Invalid payload","errorType":"exception","errorClass":"Error","httpStatus":500,"severity":"error","filePath":"apps/meteor/server/modules/core-apps/nps.module.ts","lineNumber":20,"sourceCode":"import { Banner, NPS } from '@rocket.chat/core-services';\nimport type * as UiKit from '@rocket.chat/ui-kit';\n\nimport { createModal } from './nps/createModal';\n\nexport class Nps implements IUiKitCoreApp {\n\tappId = 'nps-core';\n\n\tasync blockAction(payload: UiKitCoreAppBlockActionPayload): Promise<UiKit.ServerInteraction> {\n\t\tconst {\n\t\t\ttriggerId,\n\t\t\tactionId,\n\t\t\tcontainer: { id: viewId } = {},\n\t\t\tpayload: { value: score, blockId: npsId },\n\t\t\tuser,\n\t\t} = payload;\n\n\t\tif (!viewId || !triggerId || !user || !npsId) {\n\t\t\tthrow new Error('Invalid payload');\n\t\t}\n\n\t\tconst bannerId = viewId.replace(`${npsId}-`, '');\n\n\t\treturn createModal({\n\t\t\ttype: actionId === 'nps-score' ? 'modal.update' : 'modal.open',\n\t\t\tid: `${npsId}-${bannerId}`,\n\t\t\tappId: this.appId,\n\t\t\tnpsId,\n\t\t\ttriggerId,\n\t\t\tscore: String(score),\n\t\t\tuser,\n\t\t});\n\t}\n\n\tasync viewSubmit(payload: UiKitCoreAppViewSubmitPayload): Promise<undefined> {\n\t\tif (!payload.payload?.view?.state || !payload.payload?.view?.id) {\n\t\t\tthrow new Error('Invalid payload');","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/modules/core-apps/nps.module.ts#L2-L38","documentation":"NpsModule.blockAction (appId 'nps-core') validates the interaction payload of the Net Promoter Score survey banner: container.id (viewId), triggerId, user, and payload.blockId (the NPS id) must all be present. Any of them missing aborts with a plain 'Invalid payload' error before a modal is created.","triggerScenarios":"Dispatching a UiKitCoreAppBlockAction to nps-core (clicking a score in the NPS banner) where viewId, triggerId, user, or blockId is undefined — a hand-crafted payload, a client that dropped the container field, or banner state that went stale after the NPS survey was removed.","commonSituations":"Custom clients or bots invoking the uikit router directly with incomplete payloads; test payloads copied from another core app; survey deleted between banner render and the score click.","solutions":["Send the interaction payload exactly as the NPS banner produced it, with container.id, triggerId, user and blockId all set","If you build payloads programmatically, validate all four fields before dispatch","If the NPS no longer exists, dismiss the banner client-side instead of submitting","Log the payload at dispatch time to see which of the four fields is missing"],"exampleFix":"// before\napi.call('uiKit', { appId: 'nps-core', actionId: 'nps-score', payload: { value: '10' } }); // throws 'Invalid payload'\n\n// after\napi.call('uiKit', {\n  appId: 'nps-core',\n  actionId: 'nps-score',\n  triggerId,\n  container: { id: viewId },\n  user,\n  payload: { blockId: npsId, value: '10' },\n});","handlingStrategy":"validation","validationCode":"const isNpsBlockActionValid = (p: any): boolean =>\n  Boolean(p?.container?.id && p?.triggerId && p?.user && p?.payload?.blockId);","typeGuard":"type NpsBlockAction = {\n  container: { id: string };\n  triggerId: string;\n  user: unknown;\n  payload: { blockId: string; value?: string };\n};\n\nconst isNpsBlockAction = (p: unknown): p is NpsBlockAction =>\n  typeof p === 'object' && p !== null &&\n  typeof (p as NpsBlockAction).container?.id === 'string' &&\n  typeof (p as NpsBlockAction).triggerId === 'string' &&\n  !!(p as NpsBlockAction).user &&\n  typeof (p as NpsBlockAction).payload?.blockId === 'string';","tryCatchPattern":null,"preventionTips":["Pass the whole interaction object from render to dispatch — never rebuild it field by field","Add payload-shape assertions in dev builds for every UiKit dispatch","Drop NPS banner interactions as soon as the survey is dismissed or expires locally"],"tags":["uikit","nps","payload-validation","rocket-chat-server"],"backgroundTag":"uikit-payload-validation-failed","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}