{"record":{"id":"e11975b33103a0fd","repo":"flowable/flowable-engine","slug":"set-of-case-instance-ids-is-empty-e11975","errorCode":null,"errorMessage":"Set of case instance ids is empty","messagePattern":"Set of case instance ids is empty","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java","lineNumber":166,"sourceCode":"    public PlanItemInstanceQuery caseInstanceId(String caseInstanceId) {\n        if (caseInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"Case instance id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.caseInstanceId = caseInstanceId;\n        } else {\n            this.caseInstanceId = caseInstanceId;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery caseInstanceIds(Set<String> caseInstanceIds) {\n        if (caseInstanceIds == null) {\n            throw new FlowableIllegalArgumentException(\"Set of case instance ids is null\");\n        }\n        if (caseInstanceIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of case instance ids is empty\");\n        }\n\n        if (inOrStatement) {\n            this.currentOrQueryObject.caseInstanceIds = caseInstanceIds;\n        } else {\n            this.caseInstanceIds = caseInstanceIds;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery stageInstanceId(String stageInstanceId) {\n        if (stageInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"Stage instance id is null\");\n        }\n        if (inOrStatement) {\n            this.currentOrQueryObject.stageInstanceId = stageInstanceId;\n        } else {","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java#L148-L184","documentation":"Flowable's PlanItemInstanceQuery.caseInstanceIds(Set<String>) throws FlowableIllegalArgumentException when the set is empty. An empty IN() clause would be invalid SQL and would semantically match nothing, so Flowable rejects it up front. Callers must either supply at least one id or omit the filter.","triggerScenarios":"Calling caseInstanceIds(new HashSet<>()) or caseInstanceIds(Collections.emptySet()) — common when the id set was populated by a prior query/list operation that returned zero results (e.g. filtering by a tenant or state that matches nothing).","commonSituations":"Downstream of another query whose result set was empty; batch jobs on fresh databases; REST clients sending an empty ids array which is mapped to an empty set.","solutions":["Check set contents before querying: if empty, return an empty result immediately instead of executing the query","Skip the caseInstanceIds filter when the set is empty (though that changes semantics to 'all cases' — usually not intended)","Fix the upstream id-collection logic so it actually finds the case instances you expect"],"exampleFix":"// before\nquery.caseInstanceIds(collectedIds); // throws when collectedIds.isEmpty()\n\n// after\nif (collectedIds.isEmpty()) {\n    return Collections.emptyList();\n}\nquery.caseInstanceIds(collectedIds);","handlingStrategy":"validation","validationCode":"if (caseInstanceIds.isEmpty()) {\n    return Collections.emptyList();\n}\nquery.caseInstanceIds(caseInstanceIds);","typeGuard":"boolean isNonEmpty(Set<String> s) { return s != null && !s.isEmpty(); }","tryCatchPattern":"try {\n    query.caseInstanceIds(caseInstanceIds);\n} catch (FlowableIllegalArgumentException e) {\n    return Collections.emptyList();\n}","preventionTips":["Check isEmpty() on any id collection sourced from another query before using it in an IN-style filter","Short-circuit queries with empty filter sets instead of executing them","Document that empty collections are rejected, not treated as wildcards"],"tags":["flowable","cmmn","query","empty-collection"],"backgroundTag":"empty-required-field","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"}