{"record":{"id":"89e5c60b61ed10fd","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-integration-89e5c6","errorCode":"error-invalid-integration","errorMessage":"Invalid integration","messagePattern":"Invalid integration","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/integrations/incoming/deleteIncomingIntegration.ts","lineNumber":33,"sourceCode":"\nexport const deleteIncomingIntegration = async (integrationId: string, userId: string): Promise<void> => {\n\tconst canManageAllIntegrations = !!userId && (await hasPermissionAsync(userId, 'manage-incoming-integrations'));\n\tconst canManageOwnIntegrations =\n\t\t!canManageAllIntegrations && !!userId && (await hasPermissionAsync(userId, 'manage-own-incoming-integrations'));\n\n\tif (!canManageAllIntegrations && !canManageOwnIntegrations) {\n\t\tthrow new Meteor.Error('not_authorized', 'Unauthorized', {\n\t\t\tmethod: 'deleteIncomingIntegration',\n\t\t});\n\t}\n\n\tconst integration = await Integrations.removeByIdAndCreatedByIfExists({\n\t\t_id: integrationId,\n\t\t...(canManageOwnIntegrations && { createdBy: userId }),\n\t});\n\n\tif (!integration) {\n\t\tthrow new Meteor.Error('error-invalid-integration', 'Invalid integration', {\n\t\t\tmethod: 'deleteIncomingIntegration',\n\t\t});\n\t}\n\n\tvoid notifyOnIntegrationChanged(integration, 'removed');\n};\n\nMeteor.methods<ServerMethods>({\n\tasync deleteIncomingIntegration(integrationId) {\n\t\tmethodDeprecationLogger.method('deleteIncomingIntegration', '9.0.0', '/v1/integrations.remove');\n\t\tconst userId = Meteor.userId();\n\t\tif (!userId) {\n\t\t\tthrow new Meteor.Error('not_authorized', 'Unauthorized', {\n\t\t\t\tmethod: 'deleteIncomingIntegration',\n\t\t\t});\n\t\t}\n\n\t\tawait deleteIncomingIntegration(integrationId, userId);","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/integrations/incoming/deleteIncomingIntegration.ts#L15-L51","documentation":"Thrown by deleteIncomingIntegration when Integrations.removeByIdAndCreatedByIfExists returns null: nothing was deleted. Two distinct causes: (a) no integration with that _id exists, or (b) the caller only holds 'manage-own-incoming-integrations' and the query was scoped with createdBy: userId, so an existing integration created by someone else is invisible to the delete.","triggerScenarios":"Passing a wrong, clipped, or already-deleted integrationId; double-submitting a delete (first succeeds, second fails); a manage-own user deleting a colleague's integration.","commonSituations":"Stale row in a custom integrations list after another admin already removed it; ids copied with whitespace; team shares one workspace but each member owns their own webhooks.","solutions":["Verify the exact integrationId from the integrations admin screen or GET /api/v1/integrations.list before deleting","If you hold only manage-own, remember you can delete only integrations you created; ask an admin (who has manage-incoming-integrations) for others","Treat the error as benign if the goal was removal - confirm via the list endpoint that it is already gone"],"exampleFix":"// before\nawait Meteor.callAsync('deleteIncomingIntegration', 'wrongOrStaleId');\n// after\nconst { integrations } = await fetch(`${root}/api/v1/integrations.list`, { headers: authHeaders }).then(r => r.json());\nconst target = integrations.find((i) => i._id === integrationId);\nif (target) await Meteor.callAsync('deleteIncomingIntegration', target._id); // no-op if already removed","handlingStrategy":"validation","validationCode":"const { integrations } = await fetch(`${root}/api/v1/integrations.list`, { headers: authHeaders }).then((r) => r.json());\nconst owned = integrations.filter((i) => i.type === 'webhook-incoming'); // manage-own callers only see their own anyway\nif (!owned.some((i) => i._id === integrationId)) return; // already gone or not yours\nawait Meteor.callAsync('deleteIncomingIntegration', integrationId);","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('deleteIncomingIntegration', integrationId);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-integration') { /* treat as already deleted; refresh list */ }\n}","preventionTips":["Refresh the integrations list before destructive actions","Disable the row action while a delete is in flight (prevents double-submit)","Match ids exactly - copy, do not retype"],"tags":["rocket-chat","incoming-integration","not-found","meteor-method"],"backgroundTag":"integration-not-found","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"}