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

  1. Guard the call: check Comment.CommentOwner.KIND_EMAIL.equals(owner.getKind()) before invoking from().
  2. For non-email owners, build OwnerInfo via its builder or the User-based overload instead.
  3. 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

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


AI-assisted analysis of halo-dev/halo@d2f5165f9c (2026-08-14). Data as JSON: /api/errors/cd3906a8afffd3d1. Report an issue: GitHub.