{"record":{"id":"5692bee4f0328b4b","repo":"flowable/flowable-engine","slug":"identityid-is-null","errorCode":null,"errorMessage":"identityId is null","messagePattern":"identityId is null","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/cmd/AddIdentityLinkCmd.java","lineNumber":56,"sourceCode":"        super(appDefinitionId);\n        validateParams(appDefinitionId, identityId, identityIdType, identityType);\n        this.appDefinitionId = appDefinitionId;\n        this.identityId = identityId;\n        this.identityIdType = identityIdType;\n        this.identityType = identityType;\n    }\n\n    protected void validateParams(String appDefinitionId, String identityId, int identityIdType, String identityType) {\n        if (appDefinitionId == null) {\n            throw new FlowableIllegalArgumentException(\"appDefinitionId is null\");\n        }\n\n        if (identityType == null) {\n            throw new FlowableIllegalArgumentException(\"type is required when adding a new task identity link\");\n        }\n\n        if (identityId == null) {\n            throw new FlowableIllegalArgumentException(\"identityId is null\");\n        }\n\n        if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {\n            throw new FlowableIllegalArgumentException(\"identityIdType allowed values are 1 and 2\");\n        }\n    }\n\n    @Override\n    protected Void execute(CommandContext commandContext, AppDefinition appDefinition) {\n\n        if (IDENTITY_USER == identityIdType) {\n            CommandContextUtil.getIdentityLinkService().createScopeIdentityLink(appDefinition.getId(), null, ScopeTypes.APP,\n                            identityId, null, identityType);\n            \n        } else if (IDENTITY_GROUP == identityIdType) {\n            CommandContextUtil.getIdentityLinkService().createScopeIdentityLink(appDefinition.getId(), null, ScopeTypes.APP,\n                            null, identityId, identityType);\n        }","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-app-engine/src/main/java/org/flowable/app/engine/impl/cmd/AddIdentityLinkCmd.java#L38-L74","documentation":"The final required parameter check in AddIdentityLinkCmd.validateParams(): identityId (the user or group id being linked) must be non-null. A null identityId gives Flowable nothing to link, so the command rejects it before execution.","triggerScenarios":"Calling the identity-link API with identityId == null — e.g. an unset userId/groupId variable, or a user object whose id field was never loaded.","commonSituations":"Passing user.getId() from a partially hydrated entity; request payloads missing userId/groupId; confusing identityId (String user/group id) with identityIdType (int flag).","solutions":["Resolve and pass the actual user or group id string before calling the API.","Validate the incoming request payload for userId/groupId presence.","Check that the entity supplying the id is fully loaded (not a lazy/proxy field that is null)."],"exampleFix":"// before\nappService.addIdentityLink(appDefinitionId, user.getId(), 1, \"participant\"); // user.getId() may be null\n// after\nObjects.requireNonNull(user.getId(), \"userId is required\");\nappService.addIdentityLink(appDefinitionId, user.getId(), 1, \"participant\");","handlingStrategy":"validation","validationCode":"if (identityId == null || identityId.isBlank()) {\n    throw new IllegalArgumentException(\"identityId (user or group id) is required\");\n}","typeGuard":null,"tryCatchPattern":"try { appService.addIdentityLink(appDefId, identityId, idType, type); }\ncatch (FlowableIllegalArgumentException e) { log.error(\"Identity link rejected: \" + e.getMessage()); }","preventionTips":["Objects.requireNonNull the user/group id before the call","Ensure source entities are fully hydrated (id not null)","Require userId/groupId in request payloads with bean validation"],"tags":["null-argument","validation","identity-link"],"backgroundTag":"null-argument","analyzedSha":"d6d39ce1c69ff244f2d9dc6af756a9b95e865586","analyzedAt":"2026-09-11T06:41:19.413Z","contentChangedAt":"2026-09-11T06:41:19.413Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}