{"record":{"id":"4c9752a8b6612e1f","repo":"flowable/flowable-engine","slug":"processdefinitionid-is-null-4c9752","errorCode":null,"errorMessage":"processDefinitionId is null","messagePattern":"processDefinitionId is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessDefinitionCmd.java","lineNumber":46,"sourceCode":"\n    private static final long serialVersionUID = 1L;\n\n    protected String processDefinitionId;\n\n    protected String userId;\n\n    protected String groupId;\n\n    public AddIdentityLinkForProcessDefinitionCmd(String processDefinitionId, String userId, String groupId) {\n        validateParams(userId, groupId, processDefinitionId);\n        this.processDefinitionId = processDefinitionId;\n        this.userId = userId;\n        this.groupId = groupId;\n    }\n\n    protected void validateParams(String userId, String groupId, String processDefinitionId) {\n        if (processDefinitionId == null) {\n            throw new ActivitiIllegalArgumentException(\"processDefinitionId is null\");\n        }\n\n        if (userId == null && groupId == null) {\n            throw new ActivitiIllegalArgumentException(\"userId and groupId cannot both be null\");\n        }\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        ProcessDefinitionEntity processDefinition = commandContext\n                .getProcessDefinitionEntityManager()\n                .findProcessDefinitionById(processDefinitionId);\n\n        if (processDefinition == null) {\n            throw new ActivitiObjectNotFoundException(\"Cannot find process definition with id \" + processDefinitionId, ProcessDefinition.class);\n        }\n\n        processDefinition.addIdentityLink(userId, groupId);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/cmd/AddIdentityLinkForProcessDefinitionCmd.java#L28-L64","documentation":"AddIdentityLinkForProcessDefinitionCmd attaches an identity link to a process definition. validateParams requires a non-null processDefinitionId, since the command has no target to attach the link to otherwise. Flowable throws ActivitiIllegalArgumentException immediately.","triggerScenarios":"Calling repositoryService.addUserIdentityLinkForProcessDefinition(null, userId) or the groupId variant with a null processDefinitionId; constructing the command directly with a null id.","commonSituations":"The process definition id was meant to be resolved from a deployment result or process variable that was not set; confusing processDefinitionId with processDefinitionKey.","solutions":["Pass the actual process definition id (obtained from repositoryService.createProcessDefinitionQuery())","Verify the variable holding the id is populated before the call","If you only have the key, look up the latest definition id first and pass that"],"exampleFix":"// before\nrepositoryService.addUserIdentityLinkForProcessDefinition(defId, userId); // defId null\n// after\nProcessDefinition def = repositoryService.createProcessDefinitionQuery()\n    .processDefinitionKey(\"myProcess\").latestVersion().singleResult();\nrepositoryService.addUserIdentityLinkForProcessDefinition(def.getId(), userId);","handlingStrategy":"validation","validationCode":"if (processDefinitionId == null || processDefinitionId.isEmpty()) {\n    throw new IllegalArgumentException(\"processDefinitionId is required\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    repositoryService.addUserIdentityLinkForProcessDefinition(defId, userId);\n} catch (ActivitiIllegalArgumentException e) {\n    if (e.getMessage().contains(\"processDefinitionId\")) {\n        // resolve the id from a query and retry\n    } else { throw e; }\n}","preventionTips":["Resolve definition ids via ProcessDefinitionQuery, never hard-code them","Distinguish definition id from definition key","Null-check ids obtained from variables or request payloads"],"tags":["null-argument","identity-link","process-definition","validation"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-18T11:17:12.947Z"}