halo-dev/halo · error · IllegalArgumentException
Only support 'email' owner kind.
Error message
Only support 'email' owner kind.
What it means
OwnerInfo.from(Comment.CommentOwner) converts a comment owner reference into an OwnerInfo, but only supports owners whose kind equals Comment.CommentOwner.KIND_EMAIL. It throws IllegalArgumentException for any other owner kind (e.g. a user or a custom owner kind registered by a plugin).
Source
Thrown at application/src/main/java/run/halo/app/content/comment/OwnerInfo.java:43
/** Owner display name. */
String displayName;
/** Owner avatar URL. */
String avatar;
/** Owner email address when available. */
String email;
/**
* Convert user to owner info by owner that has an email kind .
*
* @param owner comment owner reference.
* @return owner info.
*/
public static OwnerInfo from(Comment.CommentOwner owner) {
if (!Comment.CommentOwner.KIND_EMAIL.equals(owner.getKind())) {
throw new IllegalArgumentException("Only support 'email' owner kind.");
}
return OwnerInfo.builder()
.kind(owner.getKind())
.name(owner.getName())
.email(owner.getName())
.displayName(owner.getDisplayName())
.avatar(owner.getAnnotation(Comment.CommentOwner.AVATAR_ANNO))
.build();
}
/**
* Convert user to owner info by {@link User}.
*
* @param user user extension.
* @return owner info.
*/
public static OwnerInfo from(User user) {
return OwnerInfo.builder()View on GitHub (pinned to d2f5165f9c)
Solutions
- Guard the call: check Comment.CommentOwner.KIND_EMAIL.equals(owner.getKind()) before invoking from().
- For non-email owners, build OwnerInfo via its builder or the User-based overload instead.
- If you are a plugin adding a new owner kind, do not route it through from(owner); provide your own mapping.
Example fix
// before
var info = OwnerInfo.from(owner); // throws when owner is a user
// after
var info = Comment.CommentOwner.KIND_EMAIL.equals(owner.getKind())
? OwnerInfo.from(owner)
: OwnerInfo.builder().kind(owner.getKind()).name(owner.getName()).build(); Defensive patterns
Strategy: type-guard
Validate before calling
if (!Comment.CommentOwner.KIND_EMAIL.equals(owner.getKind())) {
// build OwnerInfo another way (User overload / builder); do not call from(owner)
} Type guard
static boolean isEmailOwner(Comment.CommentOwner owner) {
return owner != null
&& Comment.CommentOwner.KIND_EMAIL.equals(owner.getKind());
} Prevention
- Always check owner.getKind() against KIND_EMAIL before calling OwnerInfo.from(owner).
- For user/plugin owner kinds, use the User-based overload or the builder.
- Do not assume all comment owners are email-kind when porting code from an email-only flow.
When it happens
Trigger: Calling OwnerInfo.from(owner) where owner.getKind() returns something other than the EMAIL kind constant — e.g. KIND_USER, a plugin-defined owner kind, or null.
Common situations: A plugin introduces a new comment owner kind and reuses OwnerInfo.from to render it; mixing user-authenticated comment owners with anonymous email owners in a code path that assumes email only.
Related errors
- The required parameter 'commentName' is missing.
- Unable to complete the request because the plugin configMapN
- The kind must not be null.
- The name must not be null.
- Invalid attachment
AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14).
Data as JSON: /api/errors/cd3906a8afffd3d1.
Report an issue: GitHub.