flowable/flowable-engine · error · FlowableIllegalArgumentException

Privilege name is null

Error message

Privilege name is null

What it means

CreatePrivilegeCmd's constructor throws FlowableIllegalArgumentException when the privilege name is null. Privileges in the Flowable IDM engine are identified by name, so creating one without a name is rejected at construction, before execution.

Source

Thrown at modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreatePrivilegeCmd.java:39

import org.flowable.idm.api.Privilege;
import org.flowable.idm.engine.IdmEngineConfiguration;
import org.flowable.idm.engine.impl.persistence.entity.PrivilegeEntity;
import org.flowable.idm.engine.impl.util.CommandContextUtil;

/**
 * @author Joram Barrez
 */
public class CreatePrivilegeCmd implements Command<Privilege>, Serializable {

    private static final long serialVersionUID = 1L;
    
    protected IdmEngineConfiguration idmEngineConfiguration;

    protected String name;

    public CreatePrivilegeCmd(String name, IdmEngineConfiguration idmEngineConfiguration) {
        if (name == null) {
            throw new FlowableIllegalArgumentException("Privilege name is null");
        }
        this.name = name;
        this.idmEngineConfiguration = idmEngineConfiguration;
    }

    @Override
    public Privilege execute(CommandContext commandContext) {
        long count = idmEngineConfiguration.getPrivilegeEntityManager().createNewPrivilegeQuery().privilegeName(name).count();
        if (count > 0) {
            throw new FlowableIllegalArgumentException("Provided privilege name already exists");
        }

        PrivilegeEntity entity = CommandContextUtil.getPrivilegeEntityManager(commandContext).create();
        entity.setName(name);
        CommandContextUtil.getPrivilegeEntityManager(commandContext).insert(entity);
        return entity;
    }
}

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Pass a non-null privilege name string to createPrivilege().
  2. Load privilege names from configuration and fail fast with a clear message if a required entry is absent.
  3. Validate the name (non-null, non-empty) before creating the privilege.

Example fix

// before
identityService.createPrivilege(properties.getProperty("admin.privilege")); // key missing
// after
String name = properties.getProperty("admin.privilege");
if (name != null) {
    identityService.createPrivilege(name);
} else {
    throw new IllegalStateException("admin.privilege must be configured");
}
Defensive patterns

Strategy: validation

Validate before calling

if (privilegeName != null && !privilegeName.isBlank()) { identityService.createPrivilege(privilegeName); }

Type guard

boolean validPrivilegeName(String n) { return n != null && !n.isBlank(); }

Try / catch

try { identityService.createPrivilege(name); } catch (FlowableIllegalArgumentException e) { throw new IllegalStateException("Privilege name is required", e); }

Prevention

When it happens

Trigger: Calling identityService.createPrivilege(null) (or new CreatePrivilegeCmd(null, config)) — constructors of this command validate immediately.

Common situations: Setting up custom privileges during bootstrap where the privilege names are loaded from configuration that is missing entries.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/406e9304b06a9d25. Report an issue: GitHub.