{"record":{"id":"406e9304b06a9d25","repo":"flowable/flowable-engine","slug":"privilege-name-is-null","errorCode":null,"errorMessage":"Privilege name is null","messagePattern":"Privilege name is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreatePrivilegeCmd.java","lineNumber":39,"sourceCode":"import org.flowable.idm.api.Privilege;\nimport org.flowable.idm.engine.IdmEngineConfiguration;\nimport org.flowable.idm.engine.impl.persistence.entity.PrivilegeEntity;\nimport org.flowable.idm.engine.impl.util.CommandContextUtil;\n\n/**\n * @author Joram Barrez\n */\npublic class CreatePrivilegeCmd implements Command<Privilege>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected IdmEngineConfiguration idmEngineConfiguration;\n\n    protected String name;\n\n    public CreatePrivilegeCmd(String name, IdmEngineConfiguration idmEngineConfiguration) {\n        if (name == null) {\n            throw new FlowableIllegalArgumentException(\"Privilege name is null\");\n        }\n        this.name = name;\n        this.idmEngineConfiguration = idmEngineConfiguration;\n    }\n\n    @Override\n    public Privilege execute(CommandContext commandContext) {\n        long count = idmEngineConfiguration.getPrivilegeEntityManager().createNewPrivilegeQuery().privilegeName(name).count();\n        if (count > 0) {\n            throw new FlowableIllegalArgumentException(\"Provided privilege name already exists\");\n        }\n\n        PrivilegeEntity entity = CommandContextUtil.getPrivilegeEntityManager(commandContext).create();\n        entity.setName(name);\n        CommandContextUtil.getPrivilegeEntityManager(commandContext).insert(entity);\n        return entity;\n    }\n}","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/CreatePrivilegeCmd.java#L21-L57","documentation":"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.","triggerScenarios":"Calling identityService.createPrivilege(null) (or new CreatePrivilegeCmd(null, config)) — constructors of this command validate immediately.","commonSituations":"Setting up custom privileges during bootstrap where the privilege names are loaded from configuration that is missing entries.","solutions":["Pass a non-null privilege name string to createPrivilege().","Load privilege names from configuration and fail fast with a clear message if a required entry is absent.","Validate the name (non-null, non-empty) before creating the privilege."],"exampleFix":"// before\nidentityService.createPrivilege(properties.getProperty(\"admin.privilege\")); // key missing\n// after\nString name = properties.getProperty(\"admin.privilege\");\nif (name != null) {\n    identityService.createPrivilege(name);\n} else {\n    throw new IllegalStateException(\"admin.privilege must be configured\");\n}","handlingStrategy":"validation","validationCode":"if (privilegeName != null && !privilegeName.isBlank()) { identityService.createPrivilege(privilegeName); }","typeGuard":"boolean validPrivilegeName(String n) { return n != null && !n.isBlank(); }","tryCatchPattern":"try { identityService.createPrivilege(name); } catch (FlowableIllegalArgumentException e) { throw new IllegalStateException(\"Privilege name is required\", e); }","preventionTips":["Verify configuration keys supplying privilege names exist before bootstrap","Use @NotBlank validation on configuration-bound fields","Fail fast at startup when a required privilege name is missing"],"tags":["flowable","idm","null-argument","privilege","command"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}