{"record":{"id":"92bd7c0d765316d1","repo":"flowable/flowable-engine","slug":"includeended-is-not-allowed-within-an-or-query","errorCode":null,"errorMessage":"includeEnded is not allowed within an or query","messagePattern":"includeEnded is not allowed within an or query","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":686,"sourceCode":"        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery ended() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.ended = true;\n            includeEnded = true;\n        } else {\n            this.ended = true;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery includeEnded() {\n        if (inOrStatement) {\n            throw new FlowableIllegalArgumentException(\"includeEnded is not allowed within an or query\");\n        } else {\n            this.includeEnded = true;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery started() {\n        if (inOrStatement) {\n            this.currentOrQueryObject.started = true;\n        } else {\n            this.started = true;\n        }\n        return this;\n    }\n\n    @Override\n    public PlanItemInstanceQuery notStarted() {","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/runtime/PlanItemInstanceQueryImpl.java#L668-L704","documentation":"PlanItemInstanceQueryImpl.includeEnded() throws FlowableIllegalArgumentException when called inside an or-statement (between .or() and .endOr()). Including ended plan item instances is a query-level result-shaping flag, not a filterable column, so Flowable forbids combining it with or-criteria. The query must call includeEnded() only on the top-level query object.","triggerScenarios":"Calling query.or().planItemInstanceXxx(...).includeEnded().endOr() or any placement of includeEnded() while inOrStatement is true.","commonSituations":"Developers chaining all criteria uniformly inside an or() block without realizing some flags are or-incompatible; refactoring a flat query into an or query by moving every method call inside or().","solutions":["Move includeEnded() outside the or() ... endOr() block, onto the top-level query","Chain it before or after the or clause: query.includeEnded().or()...endOr()","Remove includeEnded() if ended instances should not be included","Rebuild the chain so only column-comparison criteria live inside the or block"],"exampleFix":"// before\nquery.or().planItemInstanceEndedAfter(date).includeEnded().endOr();\n// after\nquery.includeEnded().or().planItemInstanceEndedAfter(date).endOr();","handlingStrategy":"validation","validationCode":"// includeEnded is a top-level flag: set it outside or() ... endOr()\nquery.includeEnded().or()/* criteria */.endOr();","typeGuard":null,"tryCatchPattern":"try {\n    query.includeEnded();\n} catch (FlowableIllegalArgumentException e) {\n    throw new IllegalStateException(\"includeEnded must be called outside an or() block\", e);\n}","preventionTips":["Only column-comparison criteria belong inside or() blocks; keep flags like includeEnded at top level","Review query chains after refactoring flat queries into or queries","Document or-incompatible methods in team query-builder helpers"],"tags":["flowable","cmmn","query","or-query"],"backgroundTag":"unsupported-operation","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"}