enonic / xp

Enonic XP
https://enonic.com
GNU General Public License v3.0
198 stars 34 forks source link

CreateRoleParams displayName is optional, but throws java.lang.NullPointerException #10486

Closed ComLock closed 3 months ago

ComLock commented 3 months ago
createRole({
    name: 'roleName'
});

causes

2024-03-27 09:55:49,465 ERROR c.e.xp.portal.impl.main.MainExecutor - Error while executing com.acme.example.tsup Application controller
java.util.concurrent.CompletionException: java.lang.NullPointerException: displayName is required for a role

The documentation is unclear https://developer.enonic.com/docs/xp/stable/api/lib-auth#createrole

Sidenote: I appUsers it's not possible to create a role without displayName. The name is just sanitized displayName.

We have two possible solutions:

  1. Make displayName required in the type and documentation OR
  2. Make it possible to create a role without passing displayName
alansemenov commented 3 months ago

We won't change Java API (for now, at least), so displayName will have to stay required. We have to fix the TS code though, because displayName is currently nullable there (for users and groups as well). Added a separate task for the docs: https://github.com/enonic/doc-xp/issues/523.