flowable/flowable-engine · error · FlowableIllegalArgumentException
Provided privilege name already exists
Error message
Provided privilege name already exists
What it means
CreatePrivilegeCmd.execute(CommandContext) throws FlowableIllegalArgumentException when a privilege with the given name already exists. It runs a PrivilegeQuery count by name first and rejects duplicates to keep privilege names unique in the IDM schema. This is a uniqueness violation, not a null-argument case.
Source
Thrown at modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreatePrivilegeCmd.java:49
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
- Check existence first and skip creation: query privileges by name and create only if absent.
- Wrap creation in try-catch for FlowableIllegalArgumentException and treat 'already exists' as success in idempotent bootstrap code.
- Ensure privilege-seeding logic runs exactly once (upgrade scripts / feature-flagged bootstrap) instead of on every startup.
Example fix
// before
identityService.createPrivilege("access-moderator");
// after
if (identityService.createPrivilegeQuery().privilegeName("access-moderator").count() == 0) {
identityService.createPrivilege("access-moderator");
} Defensive patterns
Strategy: try-catch
Validate before calling
if (identityService.createPrivilegeQuery().privilegeName(name).count() > 0) { return; } identityService.createPrivilege(name); Try / catch
try { identityService.createPrivilege(name); } catch (FlowableIllegalArgumentException e) { log.info("Privilege {} already exists, skipping", name); } Prevention
- Make bootstrap seeding idempotent with an existence check before creation
- Guard against concurrent seeding across clustered nodes
- Only seed privileges in upgrade scripts, not on every startup
When it happens
Trigger: Calling identityService.createPrivilege("access-moderator") when a privilege with that exact name was already persisted (e.g. by an earlier bootstrap run or another node).
Common situations: Re-running privilege seeding scripts on an existing database; multiple application instances performing idempotent-looking bootstrap concurrently.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- Could not find or create ${privilegeName} privilege
- Privilege name is null
- id is null
- name is null
- privilegeId is null
AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11).
Data as JSON: /api/errors/275357af3bea1412.
Report an issue: GitHub.