{"record":{"id":"5b01cb6c71b9ff25","repo":"flowable/flowable-engine","slug":"cannot-use-executionids-together-with-excludelocal-5b01cb","errorCode":null,"errorMessage":"Cannot use executionIds together with excludeLocalVariables","messagePattern":"Cannot use executionIds together with excludeLocalVariables","errorType":"validation","errorClass":"FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java","lineNumber":107,"sourceCode":"            throw new FlowableIllegalArgumentException(\"Execution id is null\");\n        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use executionId together with excludeLocalVariables\");\n        }\n        this.executionId = executionId;\n        return this;\n    }\n\n    @Override\n    public VariableInstanceQueryImpl executionIds(Set<String> executionIds) {\n        if (executionIds == null) {\n            throw new FlowableIllegalArgumentException(\"executionIds is null\");\n        }\n        if (executionIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of executionIds is empty\");\n        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use executionIds together with excludeLocalVariables\");\n        }\n        this.executionIds = executionIds;\n        return this;\n    }\n\n    public VariableInstanceQuery activityInstanceId(String activityInstanceId) {\n        this.activityInstanceId = activityInstanceId;\n        return this;\n    }\n\n    @Override\n    public VariableInstanceQuery taskId(String taskId) {\n        if (taskId == null) {\n            throw new FlowableIllegalArgumentException(\"taskId is null\");\n        }\n        if (excludeTaskRelated) {\n            throw new FlowableIllegalArgumentException(\"Cannot use taskId together with excludeTaskVariables\");\n        }","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java#L89-L125","documentation":"Like executionId, executionIds(Set<String>) cannot be combined with excludeLocalVariables. Flowable considers excluding local variables while filtering by execution ids contradictory, and throws FlowableIllegalArgumentException during query construction.","triggerScenarios":"Calling variableInstanceQuery.excludeLocalVariables().executionIds(ids) (in either order) on the VariableInstanceQuery API.","commonSituations":"Reusing a shared query-building helper that unconditionally calls excludeLocalVariables, then adding an executionIds filter in a specific code path.","solutions":["Remove excludeLocalVariables() when filtering by executionIds","Extract a separate query path that does not set the exclusion flag","Post-filter results by variable scope in application code instead"],"exampleFix":"// before\nquery.excludeLocalVariables().executionIds(ids);\n// after\nquery.executionIds(ids);","handlingStrategy":"validation","validationCode":"if (excludeLocal && executionIds != null) {\n    throw new IllegalArgumentException(\"excludeLocalVariables cannot be combined with executionIds\");\n}","typeGuard":"boolean isCompatibleQuery(VariableInstanceQuery q) { return q != null; } // guard the flag combination at call site","tryCatchPattern":"try {\n    query.executionIds(executionIds);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"excludeLocalVariables\")) {\n        query = createBaseQuery().executionIds(executionIds);\n    } else { throw e; }\n}","preventionTips":["Keep exclusion flags and id filters in mutually exclusive builder paths","Code-review shared query helpers for unconditional flag setting","Test both call orders (flag-then-filter and filter-then-flag) since checks run on both"],"tags":["flowable","query-validation","mutually-exclusive","variable-instance-query"],"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"}