{"record":{"id":"9c1a463cbba59c99","repo":"flowable/flowable-engine","slug":"type-is-required-when-adding-a-new-case-instance-i","errorCode":null,"errorMessage":"type is required when adding a new case instance identity link","messagePattern":"type is required when adding a new case instance identity link","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseInstanceCmd.java","lineNumber":57,"sourceCode":"\n    protected String type;\n\n    public AddIdentityLinkForCaseInstanceCmd(String caseInstanceId, String userId, String groupId, String type) {\n        validateParams(caseInstanceId, userId, groupId, type);\n        this.caseInstanceId = caseInstanceId;\n        this.userId = userId;\n        this.groupId = groupId;\n        this.type = type;\n    }\n\n    protected void validateParams(String caseInstanceId, String userId, String groupId, String type) {\n\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is null\");\n        }\n\n        if (type == null) {\n            throw new FlowableIllegalArgumentException(\"type is required when adding a new case instance identity link\");\n        }\n\n        if (userId == null && groupId == null) {\n            throw new FlowableIllegalArgumentException(\"userId and groupId cannot both be null\");\n        }\n\n    }\n\n    @Override\n    public Void execute(CommandContext commandContext) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        CaseInstanceEntityManager caseInstanceEntityManager = cmmnEngineConfiguration.getCaseInstanceEntityManager();\n        CaseInstanceEntity caseInstance = caseInstanceEntityManager.findById(caseInstanceId);\n\n        if (caseInstance == null) {\n            throw new FlowableObjectNotFoundException(\"Cannot find case instance with id \" + caseInstanceId, CaseInstanceEntity.class);\n        }\n","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/AddIdentityLinkForCaseInstanceCmd.java#L39-L75","documentation":"AddIdentityLinkForCaseInstanceCmd.validateParams throws FlowableIllegalArgumentException when the identity link 'type' (e.g. 'participant', 'owner', custom type) is null. Flowable requires every identity link to carry a type so it can be categorized when persisted to the identity link tables. The command refuses to run rather than persisting an uncategorized link.","triggerScenarios":"Calling CmmnRuntimeService.addUserIdentityLinkForCaseInstance(caseInstanceId, userId) style APIs or constructing AddIdentityLinkForCaseInstanceCmd directly with a null type parameter — e.g. passing a null link type variable from configuration or a REST request body missing the 'type' field.","commonSituations":"REST clients omitting the type field in the request body; custom code building identity links where the type comes from an unset enum/config value; migration scripts copying links from process instances without mapping the type.","solutions":["Pass a valid identity link type (e.g. IdentityLinkType.PARTICIPANT or a custom string) when calling addIdentityLink APIs","Validate the type parameter is non-null in your own code before invoking the runtime service","If the type comes from a REST payload or config, add defaulting logic (e.g. default to \"participant\")"],"exampleFix":"// before\ncmmnRuntimeService.addIdentityLinkForCaseInstance(caseInstanceId, userId, null);\n// after\ncmmnRuntimeService.addIdentityLinkForCaseInstance(caseInstanceId, userId, IdentityLinkType.PARTICIPANT);","handlingStrategy":"validation","validationCode":"if (type == null || type.isEmpty()) throw new IllegalArgumentException(\"identity link type is required\");","typeGuard":"boolean hasType(String t) { return t != null && !t.isEmpty(); }","tryCatchPattern":"try {\n    cmmnRuntimeService.addIdentityLinkForCaseInstance(caseId, userId, type);\n} catch (FlowableIllegalArgumentException e) {\n    log.error(\"Invalid identity link arguments: {}\", e.getMessage());\n}","preventionTips":["Use IdentityLinkType constants instead of raw strings to avoid null/typo values","Validate REST payloads for the type field before calling the engine","Default the type to \"participant\" when callers may omit it"],"tags":["flowable","cmmn","identity-link","validation"],"backgroundTag":"missing-required-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"}