halo-dev/halo · error · Error

User permissions not set in PermissionUtils

Error message

User permissions not set in PermissionUtils

What it means

Thrown during install()/upgrade() when every named dependency exists but at least one is at a version that fails the declared version constraint. It is PluginDependencyException.WrongVersionsException (ServerWebInputException, HTTP 400, problem type https://halo.run/probs/plugin-dependencies-with-wrong-versions); the body's `versions` field is a List of pf4j WrongDependencyVersion describing each mismatch.

Source

Thrown at ui/packages/shared/src/utils/permission.ts:39

   *              Defaults to true.
   * @returns true if the permission check passes, false otherwise
   *
   * @throws Error if user permissions are not set
   *
   * @example
   * ```ts
   * import { utils } from "@halo-dev/ui-shared"
   *
   * // Check if user has any of the permissions
   * utils.permission.has(['core:posts:manage'], true);
   *
   * // Check if user has all of the permissions
   * utils.permission.has(['core:posts:view', 'core:attachments:view'], false);
   * ```
   */
  has(permissions: Array<string>, any: boolean = true): boolean {
    if (!this.userPermissions) {
      throw new Error("User permissions not set in PermissionUtils");
    }

    // Super user with wildcard permission has all permissions
    if (this.userPermissions.includes("*")) {
      return true;
    }

    // If no permissions are required, access is granted
    if (!permissions.length) {
      return true;
    }

    // If user has no permissions, access is denied
    if (!this.userPermissions.length) {
      return false;
    }

    if (any) {

View on GitHub (pinned to d2f5165f9c)

Solutions

  1. Upgrade each offending dependency plugin to a version satisfying the constraint — see the expected versions in the body `versions` list.
  2. Relax the version constraint in plugin.yaml to match the deployed dependency version (only if the plugin truly still works).
  3. Reinstall the dependency at the exact version the plugin was built and tested against.

Example fix

// before — too strict for installed dependency
spec:
  pluginDependencies:
    plugin-comment: ">=2.0.0"
// after — match the deployed 1.x line
spec:
  pluginDependencies:
    plugin-comment: ">=1.4.0"
Defensive patterns

Strategy: validation

Validate before calling

// Check each declared constraint against the resolved dependency version.
Map<String, String> deps = candidate.getSpec().getPluginDependencies();
for (var entry : deps.entrySet()) {
    PluginWrapper w = pluginManager.getPlugin(entry.getKey());
    if (w != null && !VersionUtils.satisfiesRequires(
            w.getDescriptor().getVersion(), entry.getValue())) {
        // version mismatch — upgrade dependency or relax constraint before upload
    }
}

Try / catch

pluginService.upgrade(name, path)
    .onErrorResume(PluginDependencyException.WrongVersionsException.class, e -> {
        var versions = e.getBody().getProperty("versions");
        return Mono.error(new BusinessException("Version mismatch: " + versions));
    })

Prevention

When it happens

Trigger: install()/upgrade() with a plugin whose pluginDependencies specifies a version constraint (e.g. ">=2.0.0") that the currently installed dependency version does not satisfy.

Common situations: Requiring a newer minor of a dependency than is deployed; downgrading a dependency below a plugin's stated floor; mixing plugins built against different dependency versions.

Related errors


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