{"record":{"id":"9514b8c8c986883a","repo":"flowable/flowable-engine","slug":"privilegeid-is-null","errorCode":null,"errorMessage":"privilegeId is null","messagePattern":"privilegeId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":400,"severity":"error","filePath":"modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/GetPrivilegeMappingsByPrivilegeIdCmd.java","lineNumber":36,"sourceCode":"\nimport org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.idm.api.PrivilegeMapping;\nimport org.flowable.idm.engine.impl.util.CommandContextUtil;\n\n/**\n * @author Tijs Rademakers\n */\npublic class GetPrivilegeMappingsByPrivilegeIdCmd implements Command<List<PrivilegeMapping>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n\n    protected String privilegeId;\n\n    public GetPrivilegeMappingsByPrivilegeIdCmd(String privilegeId) {\n        if (privilegeId == null) {\n            throw new FlowableIllegalArgumentException(\"privilegeId is null\");\n        }\n        this.privilegeId = privilegeId;\n    }\n\n    @Override\n    public List<PrivilegeMapping> execute(CommandContext commandContext) {\n        return CommandContextUtil.getPrivilegeMappingEntityManager(commandContext).getPrivilegeMappingsByPrivilegeId(privilegeId);\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":46,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-idm-engine/src/main/java/org/flowable/idm/engine/impl/cmd/GetPrivilegeMappingsByPrivilegeIdCmd.java#L18-L46","documentation":"GetPrivilegeMappingsByPrivilegeIdCmd's constructor rejects a null privilegeId because privilege mappings are keyed by the privilege's id. The fail-fast FlowableIllegalArgumentException is thrown before the query executes.","triggerScenarios":"Calling IdentityService.getPrivilegeMappingsByPrivilegeId(null) or constructing new GetPrivilegeMappingsByPrivilegeIdCmd(null), e.g. when listing which users/groups hold a privilege whose id was never resolved.","commonSituations":"Authorization admin screens where a privilege row's id is null (unsaved privilege); id resolution by name that failed silently; API clients omitting the privilegeId query parameter.","solutions":["Pass a non-null privilegeId to IdentityService.getPrivilegeMappingsByPrivilegeId().","Resolve the privilege first and handle the not-found case instead of passing a null id.","Validate the request parameter at the controller layer before invoking the engine.","Catch FlowableIllegalArgumentException and return a 'privilegeId required' validation response."],"exampleFix":"// before\nList<PrivilegeMapping> mappings = identityService.getPrivilegeMappingsByPrivilegeId(privilegeId); // may be null\n\n// after\nObjects.requireNonNull(privilegeId, \"privilegeId is required\");\nList<PrivilegeMapping> mappings = identityService.getPrivilegeMappingsByPrivilegeId(privilegeId);","handlingStrategy":"validation","validationCode":"if (privilegeId == null || privilegeId.isEmpty()) {\n    throw new IllegalArgumentException(\"privilegeId must be provided before querying privilege mappings\");\n}","typeGuard":"boolean hasValidPrivilegeId(String privilegeId) {\n    return privilegeId != null && !privilegeId.isEmpty();\n}","tryCatchPattern":"try {\n    List<PrivilegeMapping> mappings = identityService.getPrivilegeMappingsByPrivilegeId(privilegeId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"privilegeId is null\")) {\n        throw new InvalidRequestException(\"privilegeId must not be null\");\n    }\n    throw e;\n}","preventionTips":["Resolve privileges by id with an explicit not-found branch before listing mappings.","Validate the privilegeId request parameter before invoking the engine.","Never pass the id of an unsaved Privilege object; save it first.","Add contract tests for mapping queries with missing ids."],"tags":["flowable","idm","null-check","privilege"],"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"}