halo-dev/halo · warning · ServerWebInputException

menuName is required.

Error message

menuName is required.

What it means

MenuItemConsoleService.normalizeRequired(value, message) trims-and-checks a required string and throws ServerWebInputException (HTTP 400) with the supplied message when the value is blank. The 'menuName is required.' variant fires when the menu name for a menu item operation is missing — every menu item must belong to a menu.

Source

Thrown at application/src/main/java/run/halo/app/core/endpoint/console/MenuItemConsoleService.java:289

            if (item.getSpec() == null) {
                item.setSpec(new MenuItem.MenuItemSpec());
            }
            item.getSpec().setParent(parentName);
            item.getSpec().setPriority(i);
        }
    }

    private static boolean hasHierarchyChanged(MenuItem item, HierarchyState original) {
        if (original == null) {
            return false;
        }
        return !Objects.equals(parentNameOf(item), original.parentName()) || priorityOf(item) != original.priority();
    }

    private static String normalizeRequired(String value, String message) {
        var normalized = normalize(value);
        if (normalized == null) {
            throw new ServerWebInputException(message);
        }
        return normalized;
    }

    private static String normalize(String value) {
        return org.springframework.util.StringUtils.hasText(value) ? value : null;
    }

    private record HierarchyState(String parentName, int priority) {}
}

View on GitHub (pinned to d2f5165f9c)

Solutions

  1. Always provide a non-blank menuName (the target menu's metadata.name) when creating/updating a menu item.
  2. On the client, ensure a menu is selected before the item save action is enabled.
  3. When importing, set menuName on every item before submission.

Example fix

// before
POST /menu-items { "spec": { "displayName": "Home" } } // 400

// after
POST /menu-items { "spec": { "menuName": "main-menu", "displayName": "Home" } }
Defensive patterns

Strategy: validation

Validate before calling

if (!StringUtils.hasText(menuName)) {
    return Mono.error(new ServerWebInputException("menuName is required."));
}

Type guard

static boolean hasMenuName(String s) { return StringUtils.hasText(s); }

Prevention

When it happens

Trigger: Creating or updating a menu item via the console endpoint without specifying which menu (menuName) it belongs to, or passing an empty/whitespace menuName.

Common situations: Frontend bug dropping the menuName field when saving a menu item; importing menu items without a menu reference; a plugin creating menu items programmatically and omitting the parent menu name.

Related errors


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