theonedev/onedev · error · NotAcceptableException
Primary email address not set or not verified for user: ${na
Error message
Primary email address not set or not verified for user: ${name} What it means
This NotAcceptableException is thrown when code requires a user's verified primary email address (e.g. for git email, notifications, or noreply address generation) but the user has either no primary email set or the primary email is unverified. OneDev refuses to expose/use an unverified address.
Source
Thrown at server-core/src/main/java/io/onedev/server/model/User.java:1278
public EmailAddress getPrimaryEmailAddress() {
if (primaryEmailAddress == null)
primaryEmailAddress = Optional.ofNullable(getEmailAddressService().findPrimary(this));
return primaryEmailAddress.orElse(null);
}
public void cachePrimaryEmailAddress(EmailAddress primaryEmailAddress) {
this.primaryEmailAddress = Optional.ofNullable(primaryEmailAddress);
}
public EmailAddress getGitEmailAddress() {
if (isKeepEmailAddressesPrivate() || getType() == Type.SERVICE || getType() == Type.AI) {
return newNoreplyEmailAddress();
} else {
var primaryEmailAddress = getPrimaryEmailAddress();
if (primaryEmailAddress != null && primaryEmailAddress.isVerified())
return primaryEmailAddress;
else
throw new NotAcceptableException("Primary email address not set or not verified for user: " + getName());
}
}
public EmailAddress newNoreplyEmailAddress() {
var emailAddress = new EmailAddress();
emailAddress.setValue(getName() + "@" + getNoreplyEmailDomain());
emailAddress.setOwner(this);
emailAddress.setVerificationCode(null);
return emailAddress;
}
public static String getNoreplyEmailDomain() {
return OneDev.getInstance(SettingService.class).getSystemSetting().getNoreplyEmailDomain();
}
public static String getSystemNoreplyEmailAddress() {
return User.SYSTEM_NAME.toLowerCase() + "@" + getNoreplyEmailDomain();
}View on GitHub (pinned to d44925c47c)
Solutions
- Log in as the user and set a primary email under Profile → Emails, then click the verification link
- If self-registration is restricted, have an administrator verify or set the email via the user management page (or enable auto-verification for trusted SSO)
- For service/machine users, configure a noreply email so the verified-address path is not needed
- Re-trigger the verification email if the original link expired
Example fix
// before (assuming user has verified email)
String email = user.getGitEmailAddress().getValue();
// after
var primary = user.getPrimaryEmailAddress();
if (primary == null || !primary.isVerified()) {
throw new NotAcceptableException("User must set and verify a primary email first");
}
String email = primary.getValue(); Defensive patterns
Strategy: validation
Validate before calling
var primary = user.getPrimaryEmailAddress(); boolean ok = primary != null && primary.isVerified();
Type guard
boolean hasVerifiedPrimaryEmail(User u) {
var e = u.getPrimaryEmailAddress();
return e != null && e.isVerified();
} Try / catch
try {
String email = user.getGitEmailAddress().getValue();
} catch (NotAcceptableException e) {
logger.warn("User {} lacks verified primary email", user.getName());
} Prevention
- Require email at account creation
- Prompt users to verify email after signup/SSO linking
- Check verification status in admin user audits
When it happens
Trigger: Calling the method that resolves the user's git/email address (around User.java:1278) when getPrimaryEmailAddress() is null or isVerified() is false — e.g. during push, commit attribution, or operations requiring a real email identity.
Common situations: Users created via API/script without email; email added but verification link never clicked; import/migration losing email verification state; SSO accounts lacking a verified email in OneDev.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- At least one receiver address should be specified
- Unable to create issue from email as service desk is not ena
- Invalid id specified in recipient address:
- Non-existent issue specified in recipient address:
- No permission to comment issue:
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/d16a3f4337f63ad9.
Report an issue: GitHub.