{"record":{"id":"68804dca20ae492a","repo":"flowable/flowable-engine","slug":"identityidtype-allowed-values-are-1-and-2-68804d","errorCode":null,"errorMessage":"identityIdType allowed values are 1 and 2","messagePattern":"identityIdType allowed values are 1 and 2","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddIdentityLinkCmd.java","lineNumber":68,"sourceCode":"    }\n\n    protected void validateParams(String taskId, String identityId, int identityIdType, String identityType) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId 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 && (identityIdType == IDENTITY_GROUP ||\n                (!IdentityLinkType.ASSIGNEE.equals(identityType) && !IdentityLinkType.OWNER.equals(identityType)))) {\n\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, TaskEntity task) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        if (task.getProcessDefinitionId() != null && Flowable5Util.isFlowable5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) {\n            Flowable5CompatibilityHandler compatibilityHandler = Flowable5Util.getFlowable5CompatibilityHandler();\n            compatibilityHandler.addIdentityLink(taskId, identityId, identityIdType, identityType);\n            return null;\n        }\n\n        String oldAssigneeId = task.getAssignee();\n        String oldOwnerId = task.getOwner();\n        \n        boolean assignedToNoOne = false;\n        if (IdentityLinkType.ASSIGNEE.equals(identityType)) {\n            ","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/AddIdentityLinkCmd.java#L50-L86","documentation":"AddIdentityLinkCmd.validateParams() restricts identityIdType to IDENTITY_USER (1) or IDENTITY_GROUP (2). Any other int (e.g. 0, 3) indicates a programming error in how the identity link was categorized, so Flowable throws FlowableIllegalArgumentException.","triggerScenarios":"Internal calls to the identity link service passing an identityIdType int outside {1, 2}, usually from a custom command or wrapper miscalculating the type.","commonSituations":"Custom code reusing the constants incorrectly; API version differences where a new enum value was mapped to an unexpected int.","solutions":["Use the IDENTITY_USER / IDENTITY_GROUP constants instead of raw integers.","Map user-vs-group with a conditional: user links -> 1, group links -> 2.","If wrapping the API, validate the int before delegating."],"exampleFix":"// before\ncmd.validateParams(taskId, id, 3, \"candidate\");\n// after\nint type = isGroup ? AddIdentityLinkCmd.IDENTITY_GROUP : AddIdentityLinkCmd.IDENTITY_USER;\ncmd.validateParams(taskId, id, type, \"candidate\");","handlingStrategy":"validation","validationCode":"if (identityIdType != IDENTITY_USER && identityIdType != IDENTITY_GROUP) {\n    throw new IllegalArgumentException(\"identityIdType must be 1 (user) or 2 (group)\");\n}","typeGuard":"boolean isKnownIdentityType(int t) { return t == 1 || t == 2; }","tryCatchPattern":"try {\n    identityLinkService.validateParams(taskId, id, identityIdType, type);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Bad identityIdType: {}\", e.getMessage());\n}","preventionTips":["Always use the IDENTITY_USER/IDENTITY_GROUP constants, never raw ints.","Derive the int from a boolean user-vs-group flag.","Cover the mapping with a unit test."],"tags":["invalid-value","identity-link","enum"],"backgroundTag":"invalid-enum-value","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"}