{"record":{"id":"00758a9840f1f194","repo":"flowable/flowable-engine","slug":"cannot-use-executionid-together-with-excludelocalv-00758a","errorCode":null,"errorMessage":"Cannot use executionId together with excludeLocalVariables","messagePattern":"Cannot use executionId 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":92,"sourceCode":"        return this;\n    }\n\n    @Override\n    public VariableInstanceQueryImpl processInstanceId(String processInstanceId) {\n        if (processInstanceId == null) {\n            throw new FlowableIllegalArgumentException(\"processInstanceId is null\");\n        }\n        this.processInstanceId = processInstanceId;\n        return this;\n    }\n\n    @Override\n    public VariableInstanceQueryImpl executionId(String executionId) {\n        if (executionId == null) {\n            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;","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java#L74-L110","documentation":"Flowable's VariableInstanceQuery.executionId() rejects being combined with excludeLocalVariables because execution-scoped variable lookups only make sense for local or non-local scopes, and the API treats this combination as contradictory. The check in executionId(String) throws FlowableIllegalArgumentException before any state is set. The query is never executed; this is an argument-validation failure at query-build time.","triggerScenarios":"Calling new VariableInstanceQueryImpl(...).excludeLocalVariables().executionId(\"some-exec-id\") (or executionId before excludeLocalVariables) on the VariableInstanceQuery API.","commonSituations":"Developers copy a query template that filters out local variables and then add an executionId filter, or refactor code where excludeLocalVariables was set for a task-based query and reused it for an execution-scoped query.","solutions":["Remove the excludeLocalVariables() call from the query","If you need both filtering semantics, split into two queries: one with executionId and one with excludeLocalVariables for a different scope","Use includeNonLocalVariables or no exclusion flag and post-filter results instead"],"exampleFix":"// before\nvariableInstanceQuery.excludeLocalVariables().executionId(executionId);\n// after\nvariableInstanceQuery.executionId(executionId);","handlingStrategy":"validation","validationCode":"if (excludeLocal && executionId != null) {\n    throw new IllegalArgumentException(\"excludeLocalVariables cannot be combined with executionId\");\n}","typeGuard":"boolean isCompatibleQuery(VariableInstanceQuery q) { return q != null; } // no runtime narrowing available; guard is done at call site","tryCatchPattern":"try {\n    query.executionId(executionId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"excludeLocalVariables\")) {\n        query = createBaseQuery(); // rebuild without exclusion flag\n        query.executionId(executionId);\n    } else { throw e; }\n}","preventionTips":["Never mix excludeLocalVariables/excludeTaskVariables with execution/task filters","Build queries in one place so flag combinations are reviewable","Add unit tests asserting the exclusion flags are unset for id-scoped queries"],"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"}