{"record":{"id":"6ad47e9b69b184fa","repo":"RocketChat/Rocket.Chat","slug":"not-authorized-6ad47e","errorCode":"not_authorized","errorMessage":"Unauthorized","messagePattern":"Unauthorized","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/integrations/outgoing/replayOutgoingIntegration.ts","lineNumber":18,"sourceCode":"import type { ServerMethods } from '@rocket.chat/ddp-client';\nimport { Meteor } from 'meteor/meteor';\n\nimport { methodDeprecationLogger } from '../../../lib/deprecationWarningLogger';\nimport { replayOutgoingIntegrationMethod } from '../../../lib/integrations/functions/clearIntegrationHistory';\n\ndeclare module '@rocket.chat/ddp-client' {\n\t// eslint-disable-next-line @typescript-eslint/naming-convention\n\tinterface ServerMethods {\n\t\treplayOutgoingIntegration(params: { integrationId: string; historyId: string }): Promise<boolean>;\n\t}\n}\n\nMeteor.methods<ServerMethods>({\n\tasync replayOutgoingIntegration({ integrationId, historyId }) {\n\t\tmethodDeprecationLogger.method('replayOutgoingIntegration', '9.0.0', '/v1/integrations.replayOutgoing');\n\t\tif (!this.userId) {\n\t\t\tthrow new Meteor.Error('not_authorized', 'Unauthorized', { method: 'replayOutgoingIntegration' });\n\t\t}\n\t\tawait replayOutgoingIntegrationMethod(this.userId, { integrationId, historyId });\n\t\treturn true;\n\t},\n});\n","sourceCodeStart":1,"sourceCodeEnd":24,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/integrations/outgoing/replayOutgoingIntegration.ts#L1-L24","documentation":"The replayOutgoingIntegration method wrapper throws not_authorized 'Unauthorized' when this.userId is unset — replaying a stored outgoing-integration history entry requires an authenticated DDP session. The wrapper then delegates to replayOutgoingIntegrationMethod with the resolved userId.","triggerScenarios":"Meteor.call('replayOutgoingIntegration', { integrationId, historyId }) while logged out or on a connection whose session expired.","commonSituations":"Long-open integration history pages where the resumed login carries no user; automation attempting webhook replays over DDP.","solutions":["Log in and retry the replay","Use POST /v1/integrations.replayOutgoing with X-Auth-Token/X-User-Id for scripted replays","Verify the history entry exists (integration history UI or API) so a missing-record error is not masked by the auth failure"],"exampleFix":"// before\nMeteor.call('replayOutgoingIntegration', { integrationId, historyId });\n\n// after\nif (!Meteor.userId()) {\n  throw new Meteor.Error('not_authorized', 'Login required');\n}\nawait Meteor.callAsync('replayOutgoingIntegration', { integrationId, historyId });","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  throw new Meteor.Error('not_authorized', 'Login required');\n}\nawait Meteor.callAsync('replayOutgoingIntegration', { integrationId, historyId });","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('replayOutgoingIntegration', { integrationId, historyId });\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'not_authorized') {\n    // re-authenticate, then retry once\n    return;\n  }\n  throw err;\n}","preventionTips":["Authenticate before replaying history entries","Use POST /v1/integrations.replayOutgoing for automation","Keep history entry ids paired with their integration id to avoid follow-up not-found errors"],"tags":["authentication","integrations","meteor-methods"],"backgroundTag":"authentication-required","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"}