RocketChat/Rocket.Chat · error · Error

Failed to create user

Error message

Failed to create user

What it means

Error "Failed to create user" thrown in RocketChat/Rocket.Chat.

Source

Thrown at apps/meteor/server/lib/saml/lib/SAML.ts:202

				if (i18n.languages?.includes(userObject.language)) {
					newUser.language = userObject.language;
				}
			}

			// only set skipAuthServiceDefaultRoles if SAML is providing its own roles
			// otherwise, leave it as false to fallback to generic auth service default roles
			// from Accounts_Registration_AuthenticationServices_Default_Roles
			const skipAuthServiceDefaultRoles = roleNamesOrIds.length > 0;
			const userId = await Accounts.insertUserDoc({ skipAuthServiceDefaultRoles, skipNewUserRolesSetting: true }, newUser);
			user = await Users.findOneById(userId);

			if (user && userObject.channels && channelsAttributeUpdate !== true) {
				await SAML.subscribeToSAMLChannels(userObject.channels, user);
			}
		}

		if (!user) {
			throw new Error('Failed to create user');
		}
		// creating the token and adding to the user
		const stampedToken = Accounts._generateStampedLoginToken();
		await Users.addPersonalAccessTokenToUser({
			userId: user._id,
			loginTokenObject: stampedToken as unknown as IPersonalAccessToken,
		});

		const updateData: Record<string, any> = {
			'services.saml.provider': userObject.samlLogin.provider,
			'services.saml.idp': userObject.samlLogin.idp,
			'services.saml.idpSession': userObject.samlLogin.idpSession,
			'services.saml.nameID': userObject.samlLogin.nameID,
		};

		// If the user was not found through the customIdentifier property, then update it's value
		if (customIdentifierMatch === false && customIdentifierAttributeName) {
			updateData[`services.saml.${customIdentifierAttributeName}`] = userObject.attributeList.get(customIdentifierAttributeName);

View on GitHub (pinned to 2a7de45707)

Solutions

  1. Check server logs for the underlying user-creation failure (duplicate username/email, validation, or database error) and fix the conflicting data or SAML attribute mapping.

When it happens

Trigger: Thrown during SAML user provisioning when the user insert fails and no user id is returned.

Common situations: See trigger scenarios.


AI-assisted analysis of RocketChat/Rocket.Chat@2a7de45707 (2026-08-18). Data as JSON: /api/errors/a0b4af0172576ee4. Report an issue: GitHub.