{"record":{"id":"8a6a32f09d8d097a","repo":"flowable/flowable-engine","slug":"taskid-or-processinstanceid-is-required","errorCode":null,"errorMessage":"taskId or processInstanceId is required","messagePattern":"taskId or processInstanceId is required","errorType":"exception","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java","lineNumber":42,"sourceCode":"import org.flowable.identitylink.api.IdentityLinkType;\nimport org.flowable.identitylink.api.history.HistoricIdentityLink;\nimport org.flowable.identitylink.service.HistoricIdentityLinkService;\nimport org.flowable.identitylink.service.impl.persistence.entity.HistoricIdentityLinkEntity;\nimport org.flowable.task.api.history.HistoricTaskInstance;\nimport org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity;\n\n/**\n * @author Frederik Heremans\n */\npublic class GetHistoricIdentityLinksForTaskCmd implements Command<List<HistoricIdentityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    protected String taskId;\n    protected String processInstanceId;\n\n    public GetHistoricIdentityLinksForTaskCmd(String taskId, String processInstanceId) {\n        if (taskId == null && processInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId or processInstanceId is required\");\n        }\n        this.taskId = taskId;\n        this.processInstanceId = processInstanceId;\n    }\n\n    @Override\n    public List<HistoricIdentityLink> execute(CommandContext commandContext) {\n        if (taskId != null) {\n            return getLinksForTask(commandContext);\n        } else {\n            return getLinksForProcessInstance(commandContext);\n        }\n    }\n\n    @SuppressWarnings({ \"unchecked\", \"rawtypes\" })\n    protected List<HistoricIdentityLink> getLinksForTask(CommandContext commandContext) {\n        ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);\n        HistoricTaskInstanceEntity task = processEngineConfiguration.getTaskServiceConfiguration().getHistoricTaskService().getHistoricTask(taskId);","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-engine/src/main/java/org/flowable/engine/impl/cmd/GetHistoricIdentityLinksForTaskCmd.java#L24-L60","documentation":"GetHistoricIdentityLinksForTaskCmd accepts either a taskId or a processInstanceId, but throws FlowableIllegalArgumentException when both are null. It retrieves historic identity links (users/groups involved) for a task or a whole process instance, so at least one selector is required.","triggerScenarios":"new GetHistoricIdentityLinksForTaskCmd(null, null), typically when optional taskId/processInstanceId parameters both resolve to null at the call site, or when routing logic fails to populate either argument.","commonSituations":"Building a generic history viewer where the caller passes whichever id it has and both are absent; copy-pasted calls to the identity-link API without filling in parameters; tasks/instances already removed from history so the caller's ids were nulled out.","solutions":["Ensure at least one of taskId or processInstanceId is non-null before constructing the command.","Add a pre-check that raises a clear caller-side error naming the missing selector.","If neither id is available, use a different history query (e.g. query historic identity links by type/user) instead of this command."],"exampleFix":"// before\nhistoryService.findHistoricIdentityLinksForTask(taskId, processInstanceId);\n// after\nif (taskId == null && processInstanceId == null) {\n    throw new IllegalArgumentException(\"Provide taskId or processInstanceId to query historic identity links\");\n}\nhistoryService.findHistoricIdentityLinksForTask(taskId, processInstanceId);","handlingStrategy":"validation","validationCode":"if (taskId == null && processInstanceId == null) {\n    throw new IllegalArgumentException(\"Either taskId or processInstanceId must be provided\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    return historyService.findHistoricIdentityLinksForTask(taskId, processInstanceId);\n} catch (FlowableIllegalArgumentException e) {\n    return Collections.emptyList();\n}","preventionTips":["Assert one selector is present at the API boundary before calling engine commands","Validate optional request parameters for history viewers before dispatching queries","Centralize the check in a helper to avoid copy-paste drift"],"tags":["flowable","argument-validation","identity-links","history"],"backgroundTag":"mutually-exclusive-flags","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"}