{"record":{"id":"cb27b063d0d31f47","repo":"flowable/flowable-engine","slug":"cannot-use-taskids-together-with-excludelocalvaria-cb27b0","errorCode":null,"errorMessage":"Cannot use taskIds together with excludeLocalVariables","messagePattern":"Cannot use taskIds 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":127,"sourceCode":"        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        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use taskIds together with excludeLocalVariables\");\n        }\n        this.taskId = taskId;\n        return this;\n    }\n\n    @Override\n    public VariableInstanceQueryImpl taskIds(Set<String> taskIds) {\n        if (taskIds == null) {\n            throw new FlowableIllegalArgumentException(\"taskIds is null\");\n        }\n        if (taskIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"Set of taskIds is empty\");\n        }\n        if (excludeTaskRelated) {\n            throw new FlowableIllegalArgumentException(\"Cannot use taskIds together with excludeTaskVariables\");\n        }\n        if (excludeLocalVariables) {\n            throw new FlowableIllegalArgumentException(\"Cannot use taskIds together with excludeLocalVariables\");","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/VariableInstanceQueryImpl.java#L109-L145","documentation":"taskId(String) also cannot be combined with excludeLocalVariables. Flowable throws FlowableIllegalArgumentException when the local-variable exclusion flag is set while targeting a specific task, since the combination is deemed invalid. (Note the message says 'taskIds' — a known message typo — but it is raised from the singular taskId() method.)","triggerScenarios":"Calling variableInstanceQuery.excludeLocalVariables().taskId(id) in either order on the VariableInstanceQuery API.","commonSituations":"Shared query builder that always applies excludeLocalVariables for 'scope variable' queries, then a caller adds a taskId filter.","solutions":["Remove excludeLocalVariables() when filtering by taskId","Branch the query construction so the exclusion flag is only set for execution-scoped queries","Filter local vs non-local variables in application code after fetching"],"exampleFix":"// before\nquery.excludeLocalVariables().taskId(taskId);\n// after\nquery.taskId(taskId);","handlingStrategy":"validation","validationCode":"if (excludeLocal && taskId != null) {\n    throw new IllegalArgumentException(\"excludeLocalVariables cannot be combined with taskId\");\n}","typeGuard":"boolean isCompatibleQuery(VariableInstanceQuery q) { return q != null; } // enforce flag exclusivity at call site","tryCatchPattern":"try {\n    query.taskId(taskId);\n} catch (FlowableIllegalArgumentException e) {\n    if (e.getMessage().contains(\"excludeLocalVariables\")) {\n        query = createBaseQuery().taskId(taskId);\n    } else { throw e; }\n}","preventionTips":["Remember the message mentions 'taskIds' but the error comes from taskId() — match on 'excludeLocalVariables' substring","Keep exclusion flags out of task-scoped query builders","Cover both setter orders in tests because the check fires either way"],"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"}