{"record":{"id":"cc986e0ff963eef9","repo":"flowable/flowable-engine","slug":"cannot-combine-withouttaskid-with-task-string-o","errorCode":null,"errorMessage":"Cannot combine withoutTaskId() with task(String) or taskIds(Collection) in the same query","messagePattern":"Cannot combine withoutTaskId\\(\\) with task\\(String\\) or taskIds\\(Collection\\) in the same query","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java","lineNumber":122,"sourceCode":"            throw new FlowableIllegalArgumentException(\"executionId is empty\");\n        }\n        this.executionId = executionId;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery executionIds(Collection<String> executionIds) {\n        if (executionIds == null || executionIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"executionIds is null or empty\");\n        }\n        this.executionIds = executionIds;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery withoutTaskId() {\n        if (taskId != null || taskIds != null) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine withoutTaskId() with task(String) or taskIds(Collection) in the same query\");\n        }\n        this.withoutTaskId = true;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery scopeId(String scopeId) {\n        if (StringUtils.isEmpty(scopeId)) {\n            throw new FlowableIllegalArgumentException(\"scopeId is empty\");\n        }\n        this.scopeId = scopeId;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery scopeIds(Collection<String> scopeIds) {\n        this.scopeIds = scopeIds;\n        return this;","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java#L104-L140","documentation":"InternalVariableInstanceQueryImpl.withoutTaskId() throws FlowableIllegalArgumentException when taskId or taskIds was already set on the same query. 'Has no task' and 'belongs to specific task(s)' are contradictory filters, so the builder rejects the combination at construction time.","triggerScenarios":"Calling withoutTaskId() on a query where taskId(String) or taskIds(Collection) was already called on the same builder instance.","commonSituations":"Reusable query builders shared across code paths; conditional assembly where a task filter was added earlier and a later branch also enables withoutTaskId(); copy-paste filter chains.","solutions":["Call withoutTaskId() only on a fresh query with no task filters set","Restructure filter assembly so task-scoped and task-less queries are separate branches","Create two distinct queries if both result sets are required"],"exampleFix":"// before\nquery.taskId(taskId);\nquery.withoutTaskId(); // throws\n// after\nInternalVariableInstanceQuery q = createQuery();\nif (taskId != null) {\n    q.taskId(taskId);\n} else {\n    q.withoutTaskId();\n}","handlingStrategy":"validation","validationCode":"boolean conflict = useWithoutTaskId && (taskId != null || (taskIds != null && !taskIds.isEmpty())); if (conflict) throw new IllegalStateException(\"withoutTaskId cannot combine with taskId/taskIds\");","typeGuard":null,"tryCatchPattern":"try { query.withoutTaskId(); } catch (FlowableIllegalArgumentException e) { throw new QueryConfigurationException(e.getMessage(), e); }","preventionTips":["Decide the task-filter mode once before building the query","Use one builder instance per query variant","Write a helper that accepts an enum (BY_TASK | WITHOUT_TASK) instead of booleans plus ids"],"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"}