{"record":{"id":"79d4a354431c9ca9","repo":"RocketChat/Rocket.Chat","slug":"history-data-must-be-defined","errorCode":"history-data-must-be-defined","errorMessage":"The history data must be defined to replay an integration.","messagePattern":"The history data must be defined to replay an integration\\.","errorType":"validation","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/lib/integrations/lib/triggerHandler.ts","lineNumber":804,"sourceCode":"\t\t\t})\n\t\t\t.catch(async (err) => {\n\t\t\t\toutgoingLogger.error({ err });\n\t\t\t\tawait updateHistory({\n\t\t\t\t\thistoryId,\n\t\t\t\t\tstep: 'after-http-call',\n\t\t\t\t\thttpError: err,\n\t\t\t\t\thttpResult: null,\n\t\t\t\t});\n\t\t\t});\n\t}\n\n\tasync replay(integration: IOutgoingIntegration, history: IIntegrationHistory) {\n\t\tif (integration?.type !== 'webhook-outgoing') {\n\t\t\tthrow new Meteor.Error('integration-type-must-be-outgoing', 'The integration type to replay must be an outgoing webhook.');\n\t\t}\n\n\t\tif (!history?.data) {\n\t\t\tthrow new Meteor.Error('history-data-must-be-defined', 'The history data must be defined to replay an integration.');\n\t\t}\n\n\t\tconst { event } = history;\n\t\tlet owner;\n\t\tlet message;\n\t\tlet room;\n\t\tlet user;\n\n\t\tif (history.data.owner?._id) {\n\t\t\towner = await Users.findOneById(history.data.owner._id);\n\t\t}\n\t\tif (history.data.message_id) {\n\t\t\tmessage = await Messages.findOneById(history.data.message_id);\n\t\t}\n\t\tif (history.data.channel_id) {\n\t\t\troom = await Rooms.findOneById(history.data.channel_id);\n\t\t}\n\t\tif (history.data.user_id) {","sourceCodeStart":786,"sourceCodeEnd":822,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/lib/integrations/lib/triggerHandler.ts#L786-L822","documentation":"Thrown by TriggerHandler.replay() when the supplied history entry has no `data` field. Replay reconstructs the original trigger payload (event, message, room, owner) from history.data; without it there is nothing to re-send, so the server refuses with Meteor.Error code 'history-data-must-be-defined'.","triggerScenarios":"Calling integrations.replay with a historyId whose history record was written with no data (early-abort steps like 'after-prepare-no-url_or_method' still store data, but hand-crafted or pruned records may not); passing a history object built manually instead of one loaded from the integration history collection; history entries from a very old Rocket.Chat version with a different schema.","commonSituations":"Scripts that pick the first history entry rather than a completed delivery; deployments where history documents were partially purged; replaying entries whose original run failed before payload mapping.","solutions":["Select a history entry from a real execution that contains data (check GET /api/v1/integrations.history for the integration)","Prefer the latest 'after-http-call' entry so owner/message/room resolve cleanly","Do not construct history objects yourself; always replay by historyId returned by the history API"],"exampleFix":"// before\nawait replay(integration, history);\n\n// after\nif (!history?.data) {\n  throw new Error('Pick a history entry that actually stored trigger data');\n}\nawait replay(integration, history);","handlingStrategy":"validation","validationCode":"if (!history?.data) {\n  throw new Error('cannot replay: history entry has no stored trigger data');\n}\nawait replay(integration, history);","typeGuard":"const hasReplayableData = (h?: IIntegrationHistory): h is IIntegrationHistory & { data: NonNullable<IIntegrationHistory['data']> } =>\n  Boolean(h?.data);","tryCatchPattern":"try {\n  await replay(integration, history);\n} catch (err: any) {\n  if (err?.error === 'history-data-must-be-defined') {\n    // pick another historyId from integrations.history that has data\n  }\n  throw err;\n}","preventionTips":["Only expose replay for history entries whose data field is present","Prefer the most recent completed execution when choosing a historyId automatically"],"tags":["integrations","outgoing-webhook","replay","validation"],"backgroundTag":"missing-required-field","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}