{"record":{"id":"f574f1d31ca4e2a4","repo":"flowable/flowable-engine","slug":"cannot-combine-taskids-collection-with-withouttas","errorCode":null,"errorMessage":"Cannot combine taskIds(Collection) with withoutTaskId() in the same query","messagePattern":"Cannot combine taskIds\\(Collection\\) with withoutTaskId\\(\\) in the same query","errorType":"validation","errorClass":"org.flowable.common.engine.api.FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java","lineNumber":86,"sourceCode":"            throw new FlowableIllegalArgumentException(\"taskId is empty\");\n        }\n\n        if (withoutTaskId) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine taskId(String) with withoutTaskId() in the same query\");\n        }\n\n        this.taskId = taskId;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery taskIds(Collection<String> taskIds) {\n        if (taskIds == null || taskIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"taskIds is null or empty\");\n        }\n\n        if (withoutTaskId) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine taskIds(Collection) with withoutTaskId() in the same query\");\n        }\n        this.taskIds = taskIds;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery processInstanceId(String processInstanceId) {\n        if (StringUtils.isEmpty(processInstanceId)) {\n            throw new FlowableIllegalArgumentException(\"processInstanceId is empty\");\n        }\n        this.processInstanceId = processInstanceId;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery executionId(String executionId) {\n        if (StringUtils.isEmpty(executionId)) {\n            throw new FlowableIllegalArgumentException(\"executionId is empty\");","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java#L68-L104","documentation":"InternalVariableInstanceQueryImpl.taskIds(Collection<String>) throws FlowableIllegalArgumentException when withoutTaskId was already set on the same query. 'Match these specific tasks' and 'match variables with no task' are mutually exclusive filters, so the builder rejects combining them.","triggerScenarios":"Calling taskIds(collection) on a query where withoutTaskId() was already called (or vice versa) on the same builder instance.","commonSituations":"Shared/mutated query objects across code paths; conditional filter assembly where both branches fired; copy-paste filter blocks.","solutions":["Use either taskIds(...) or withoutTaskId(), never both on one query","Split into two queries if both result sets are needed","Refactor query construction so the filters are exclusive branches"],"exampleFix":"// before\nquery.withoutTaskId();\nquery.taskIds(ids); // throws\n// after\nif (ids != null && !ids.isEmpty()) {\n    query.taskIds(ids);\n} else {\n    query.withoutTaskId();\n}","handlingStrategy":"validation","validationCode":"boolean conflict = (taskIds != null && !taskIds.isEmpty()) && useWithoutTaskId; if (conflict) throw new IllegalStateException(\"taskIds and withoutTaskId are mutually exclusive\");","typeGuard":null,"tryCatchPattern":"try { buildTaskQuery(taskIds, withoutTaskId); } catch (FlowableIllegalArgumentException e) { throw new QueryConfigurationException(e.getMessage(), e); }","preventionTips":["Make task filter options mutually exclusive in your query-building API","Never reuse one query builder across mutually exclusive branches","Document that withoutTaskId excludes taskIds/taskId on the same query"],"tags":["flowable","query-builder","conflicting-filters","argument-validation"],"backgroundTag":"mutually-exclusive-options","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"}