{"record":{"id":"e80b833382f7ef0b","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-user-e80b83","errorCode":"error-invalid-user","errorMessage":"Invalid user","messagePattern":"Invalid user","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts","lineNumber":204,"sourceCode":"\t\t\t\t_updatedAt: new Date(),\n\t\t\t\t_updatedBy: await Users.findOne({ _id: userId }, { projection: { username: 1 } }),\n\t\t\t},\n\t\t},\n\t\t{ returnDocument: 'after' },\n\t);\n\n\tif (updatedIntegration) {\n\t\tvoid notifyOnIntegrationChanged(updatedIntegration);\n\t}\n\n\treturn updatedIntegration;\n};\n\nMeteor.methods<ServerMethods>({\n\tasync updateIncomingIntegration(integrationId, integration) {\n\t\tmethodDeprecationLogger.method('updateIncomingIntegration', '9.0.0', '/v1/integrations.update');\n\t\tif (!this.userId) {\n\t\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user', {\n\t\t\t\tmethod: 'updateOutgoingIntegration',\n\t\t\t});\n\t\t}\n\n\t\treturn updateIncomingIntegration(this.userId, integrationId, integration);\n\t},\n});\n","sourceCodeStart":186,"sourceCodeEnd":212,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/integrations/incoming/updateIncomingIntegration.ts#L186-L212","documentation":"The Meteor method wrapper for updateIncomingIntegration throws error-invalid-user when this.userId is unset, i.e. the DDP call arrived over a connection with no authenticated user. The error's details object carries the stale method name 'updateOutgoingIntegration' — a copy-paste artifact that can mislead log greps, so match on the error code, not the method detail.","triggerScenarios":"Meteor.callAsync('updateIncomingIntegration', ...) from a logged-out client, or from a session whose login expired and resumed without a bound user.","commonSituations":"Automation scripts or bots calling DDP methods directly without a login flow; admin UI left open past session expiry; integration tests that forget to stub this.userId.","solutions":["Log in first (Meteor.loginWithPassword / token login) and retry the method call","For scripts, switch to POST /v1/integrations.update with X-Auth-Token and X-User-Id headers","On the client, catch the error, redirect to login, and retry after re-authentication"],"exampleFix":"// before\nMeteor.call('updateIncomingIntegration', id, payload, cb);\n\n// after\nif (!Meteor.userId()) {\n  // route to login and retry after authentication\n  throw new Meteor.Error('error-invalid-user', 'Login required');\n}\nawait Meteor.callAsync('updateIncomingIntegration', id, payload);","handlingStrategy":"validation","validationCode":"if (!Meteor.userId()) {\n  // route to login instead of calling the method\n}","typeGuard":null,"tryCatchPattern":"try {\n  await Meteor.callAsync('updateIncomingIntegration', id, payload);\n} catch (err) {\n  if (err instanceof Meteor.Error && err.error === 'error-invalid-user') {\n    // session lost: prompt re-login, then retry once\n    return;\n  }\n  throw err;\n}","preventionTips":["Call integration admin methods only from authenticated sessions","Prefer REST /v1/integrations.update with token headers for scripts","Do not match this error by its method detail — the string says updateOutgoingIntegration"],"tags":["authentication","meteor-methods","integrations"],"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"}