theonedev/onedev · error · NotAcceptableException
Email address is already used by another user
Error message
Email address is already used by another user
What it means
Thrown by UserResource.createUser when the email address in the payload is already associated with another user. For ordinary users (type ORDINARY), OneDev requires unique email addresses, checked via emailAddressService.findByValue.
Source
Thrown at server-core/src/main/java/io/onedev/server/rest/resource/UserResource.java:362
throw new UnauthenticatedException();
var user = userService.findByName(name);
if (user != null)
return user.getId();
else
throw new NotFoundException();
}
@Api(order=1900, description="Create new user")
@POST
public Long createUser(@NotNull @Valid UserCreateData data) {
if (!SecurityUtils.isAdministrator())
throw new UnauthorizedException();
if (userService.findByName(data.getName()) != null)
throw new NotAcceptableException("Login name is already used by another user");
if (data.getType() == ORDINARY && emailAddressService.findByValue(data.getEmailAddress()) != null)
throw new NotAcceptableException("Email address is already used by another user");
User user = new User();
user.setType(data.getType());
user.setName(data.getName());
user.setFullName(data.getFullName());
if (data.getType() == AI)
user.setAiSetting(data.getAiSetting());
if (data.getType() != ORDINARY) {
userService.create(user);
} else {
user.setNotifyOwnEvents(data.isNotifyOwnEvents());
user.setPassword(passwordService.encryptPassword(data.getPassword()));
userService.create(user);
EmailAddress emailAddress = new EmailAddress();
emailAddress.setPrimary(true);
emailAddress.setOwner(user);
emailAddress.setValue(data.getEmailAddress());View on GitHub (pinned to d44925c47c)
Solutions
- Use an unused email address for the new account.
- Look up which user owns the email and update that user instead.
- If the account is a bot, set type to AI instead of ORDINARY to skip the email-uniqueness check.
- Clean up the stale user holding the email if appropriate.
Example fix
// before
UserCreateData d = new UserCreateData("bob2", "bob@corp.com", ORDINARY); // bob@corp.com taken
// after
UserCreateData d = new UserCreateData("bob2", "bob2@corp.com", ORDINARY); // unique email
// or for bots:
UserCreateData bot = new UserCreateData("ci-bot", "bob@corp.com", AI); Defensive patterns
Strategy: validation
Validate before calling
if (data.getType() == ORDINARY && client.emailInUse(data.getEmailAddress()))
throw new IllegalArgumentException("Email " + data.getEmailAddress() + " already registered"); Try / catch
try { return client.createUser(data); }
catch (NotAcceptableException e) {
if (e.getMessage().contains("Email address")) throw new DuplicateEmailException(e);
throw e;
} Prevention
- Maintain a unique-email constraint in your user directory before syncing.
- Use AI/robot type for service accounts to bypass ordinary-user email checks where appropriate.
- Check for stale users holding old emails during imports.
When it happens
Trigger: POST /rest/users with UserCreateData of type ORDINARY whose emailAddress is already registered to any user (only ORDINARY users are checked, so AI/robot types bypass this).
Common situations: Reusing a shared mailbox for multiple accounts; re-running import scripts; creating a user with the email of a previously deactivated user.
Related errors
- Login name is already used by another user
- This email address is already used by another user
- Unauthenticated
- Multiple users found: ${userName}
- User not found: ${userName}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/a1c764d7dcbd10d2.
Report an issue: GitHub.