{"record":{"id":"164812fe05b5611a","repo":"flowable/flowable-engine","slug":"caseinstanceid-is-required","errorCode":null,"errorMessage":"caseInstanceId is required","messagePattern":"caseInstanceId is required","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetHistoricEntityLinkChildrenForCaseInstanceCmd.java","lineNumber":38,"sourceCode":"import org.flowable.common.engine.api.FlowableIllegalArgumentException;\nimport org.flowable.common.engine.api.scope.ScopeTypes;\nimport org.flowable.common.engine.impl.interceptor.Command;\nimport org.flowable.common.engine.impl.interceptor.CommandContext;\nimport org.flowable.entitylink.api.EntityLinkType;\nimport org.flowable.entitylink.api.history.HistoricEntityLink;\n\n/**\n * @author Tijs Rademakers\n */\npublic class GetHistoricEntityLinkChildrenForCaseInstanceCmd implements Command<List<HistoricEntityLink>>, Serializable {\n\n    private static final long serialVersionUID = 1L;\n    \n    protected String caseInstanceId;\n\n    public GetHistoricEntityLinkChildrenForCaseInstanceCmd(String caseInstanceId) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"caseInstanceId is required\");\n        }\n        this.caseInstanceId = caseInstanceId;\n    }\n\n    @Override\n    public List<HistoricEntityLink> execute(CommandContext commandContext) {\n        CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration(commandContext);\n        return cmmnEngineConfiguration.getEntityLinkServiceConfiguration().getHistoricEntityLinkService()\n                .findHistoricEntityLinksByScopeIdAndScopeType(caseInstanceId, ScopeTypes.CMMN, EntityLinkType.CHILD);\n    }\n\n}\n","sourceCodeStart":20,"sourceCodeEnd":51,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/cmd/GetHistoricEntityLinkChildrenForCaseInstanceCmd.java#L20-L51","documentation":"GetHistoricEntityLinkChildrenForCaseInstanceCmd is a command that fetches the historic entity links that are children of a given case instance. The Flowable engine validates command arguments eagerly: its constructor throws FlowableIllegalArgumentException when the caseInstanceId is null, because the command cannot be executed meaningfully without an id. This fail-fast check happens before the command is ever queued in the command executor.","triggerScenarios":"Calling new GetHistoricEntityLinkChildrenForCaseInstanceCmd(null), or invoking an API path that passes a null caseInstanceId into this constructor (e.g. runtime/history service helpers resolving an id from a variable or map lookup that returned null).","commonSituations":"Developers pass the result of a lookup that returned null (e.g. map.get(\"caseId\"), a request path variable not present), or confuse caseInstanceId with planItemInstanceId/taskId when wiring service calls.","solutions":["Ensure a non-null caseInstanceId is supplied before constructing the command (check the variable/expression that provides it).","If the id comes from a lookup, fail earlier with a clear client-side error instead of passing null into the engine.","Use the history service API (e.g. historicEntityLink query APIs) with a validated id rather than building the command directly."],"exampleFix":"// before\nnew GetHistoricEntityLinkChildrenForCaseInstanceCmd(request.get(\"caseInstanceId\"));\n// after\nString caseInstanceId = request.get(\"caseInstanceId\");\nif (caseInstanceId == null) {\n    throw new IllegalArgumentException(\"caseInstanceId must be provided\");\n}\nnew GetHistoricEntityLinkChildrenForCaseInstanceCmd(caseInstanceId);","handlingStrategy":"validation","validationCode":"if (caseInstanceId == null || caseInstanceId.isEmpty()) { throw new IllegalArgumentException(\"caseInstanceId must be provided\"); }","typeGuard":"boolean hasCaseInstanceId = s != null && !s.trim().isEmpty();","tryCatchPattern":"try { ... } catch (FlowableIllegalArgumentException e) { log.error(\"Missing argument: {}\", e.getMessage()); throw new BadRequestException(e.getMessage()); }","preventionTips":["Validate ids at the service/REST boundary before invoking engine commands","Avoid passing lookup results (map.get) directly into commands","Use Objects.requireNonNull with a clear message when wiring ids"],"tags":["flowable","cmmn","null-argument","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"}