{"record":{"id":"3d4f944368be70f4","repo":"RocketChat/Rocket.Chat","slug":"email-adminuser-emails-0-address-already-exis","errorCode":null,"errorMessage":"Email ${adminUser.emails![0].address} already exists","messagePattern":"Email (.+?) already exists","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"critical","filePath":"apps/meteor/server/startup/initialData.ts","lineNumber":234,"sourceCode":"\t\t\t\t{\n\t\t\t\t\taddress: 'rocketchat.internal.admin.test@rocket.chat',\n\t\t\t\t\tverified: true,\n\t\t\t\t},\n\t\t\t],\n\t\t\tstatus: UserStatus.OFFLINE,\n\t\t\tstatusDefault: UserStatus.ONLINE,\n\t\t\tutcOffset: 0,\n\t\t\tactive: true,\n\t\t\ttype: 'user',\n\t\t};\n\n\t\tconsole.log(colors.green(`Name: ${adminUser.name}`));\n\t\tconsole.log(colors.green(`Email: ${adminUser.emails![0].address}`));\n\t\tconsole.log(colors.green(`Username: ${adminUser.username}`));\n\t\tconsole.log(colors.green(`Password: ${adminUser._id}`));\n\n\t\tif (await Users.findOneByEmailAddress(adminUser.emails![0].address)) {\n\t\t\tthrow new Meteor.Error(`Email ${adminUser.emails![0].address} already exists`, \"Rocket.Chat can't run in test mode\");\n\t\t}\n\n\t\tif (!(await checkUsernameAvailability(adminUser.username!))) {\n\t\t\tthrow new Meteor.Error(`Username ${adminUser.username} already exists`, \"Rocket.Chat can't run in test mode\");\n\t\t}\n\n\t\tawait Users.create(adminUser);\n\n\t\tawait Accounts.setPasswordAsync(adminUser._id, adminUser._id);\n\n\t\tawait addUserRolesAsync(adminUser._id, ['admin']);\n\n\t\tif (settings.get('Show_Setup_Wizard') === 'pending') {\n\t\t\t(await Settings.updateValueById('Show_Setup_Wizard', 'in_progress')).modifiedCount &&\n\t\t\t\tvoid notifyOnSettingChangedById('Show_Setup_Wizard');\n\t\t}\n\n\t\tawait addUserToDefaultChannels(adminUser as IUser, true);","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/startup/initialData.ts#L216-L252","documentation":"Startup guard in initialData.ts: when TEST_MODE is 'true' or 'api', Rocket.Chat seeds a well-known internal admin (rocketchat.internal.admin.test@rocket.chat). Before inserting, it verifies the email address is unused; if Users.findOneByEmailAddress finds a document, startup aborts with a Meteor.Error because the test fixture cannot be created safely. The error string doubles as the reason and the detail says the server can't run in test mode.","triggerScenarios":"Starting the server with TEST_MODE=true/api against a database that already contains a user with the email rocketchat.internal.admin.test@rocket.chat (leftover fixture, or a real user that claimed that address).","commonSituations":"Re-running test mode on a persistent database from a previous test run; CI reusing a database volume without reset; someone manually creating that email address.","solutions":["Drop or rename the existing user holding rocketchat.internal.admin.test@rocket.chat before restarting in test mode.","Point TEST_MODE runs at a clean database (fresh MongoDB or reset volume).","Remove leftover fixture data: Users.removeById('rocketchat.internal.admin.test') in a mongo shell, then restart."],"exampleFix":"# before: db still holds the fixture email\nmongosh rock_chat --eval 'db.users.findOne({\"emails.address\":\"rocketchat.internal.admin.test@rocket.chat\"})'\n\n# after: remove leftover fixture, then restart with TEST_MODE=true\nmongosh rock_chat --eval 'db.users.remove({_id:\"rocketchat.internal.admin.test\"})'","handlingStrategy":"validation","validationCode":"// Pre-start check: fixture email must be unused\nconst existing = await Users.findOneByEmailAddress('rocketchat.internal.admin.test@rocket.chat');\nif (existing && TEST_MODE) { /* wipe fixture users or use a clean DB before boot */ }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run TEST_MODE only against disposable databases.","Reset the Mongo volume/dataset between CI test-mode runs.","Never let real users claim the internal fixture email address."],"tags":["rocket-chat","startup","test-mode","database-seed"],"backgroundTag":"seed-data-conflict","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}