{"record":{"id":"c1b0daef5e3c273e","repo":"flowable/flowable-engine","slug":"taskids-is-null-c1b0da","errorCode":null,"errorMessage":"taskIds is null","messagePattern":"taskIds is null","errorType":"validation","errorClass":"ActivitiIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricVariableInstanceQueryImpl.java","lineNumber":118,"sourceCode":"        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQuery taskId(String taskId) {\n        if (taskId == null) {\n            throw new ActivitiIllegalArgumentException(\"taskId is null\");\n        }\n        if (excludeTaskRelated) {\n            throw new ActivitiIllegalArgumentException(\"Cannot use taskId together with excludeTaskVariables\");\n        }\n        this.taskId = taskId;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQueryImpl taskIds(Set<String> taskIds) {\n        if (taskIds == null) {\n            throw new ActivitiIllegalArgumentException(\"taskIds is null\");\n        }\n        if (taskIds.isEmpty()) {\n            throw new ActivitiIllegalArgumentException(\"Set of taskIds is empty\");\n        }\n        if (excludeTaskRelated) {\n            throw new ActivitiIllegalArgumentException(\"Cannot use taskIds together with excludeTaskVariables\");\n        }\n        this.taskIds = taskIds;\n        return this;\n    }\n\n    @Override\n    public HistoricVariableInstanceQuery excludeTaskVariables() {\n        if (taskId != null) {\n            throw new ActivitiIllegalArgumentException(\"Cannot use taskId together with excludeTaskVariables\");\n        }\n        if (taskIds != null) {\n            throw new ActivitiIllegalArgumentException(\"Cannot use taskIds together with excludeTaskVariables\");","sourceCodeStart":100,"sourceCodeEnd":136,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricVariableInstanceQueryImpl.java#L100-L136","documentation":"HistoricVariableInstanceQueryImpl.taskIds(Set<String>) validates its argument before use and throws ActivitiIllegalArgumentException when the passed set is null. A null set carries no task filter information, so the query would silently be wrong; the library fails fast instead. Pass a non-null, non-empty set of task IDs.","triggerScenarios":"historyService.createHistoricVariableInstanceQuery().taskIds(null) — e.g. when a collection that was expected to hold task IDs is null (uninitialized variable, failed lookup, absent method parameter).","commonSituations":"Passing an optional task ID list straight into taskIds() without a null check; a repository/DAO returning null instead of an empty collection; NPE-avoidance refactor replacing direct dereference with this setter that then rejects null.","solutions":["Ensure the set is initialized (e.g. new HashSet<>()) before calling taskIds().","Guard the call: only invoke taskIds() when the set is non-null; skip the filter otherwise.","Fix the upstream source that produced null instead of an empty collection."],"exampleFix":"// before\nquery.taskIds(taskIds);\n// after\nif (taskIds != null && !taskIds.isEmpty()) {\n    query.taskIds(taskIds);\n}","handlingStrategy":"type-guard","validationCode":"if (taskIds == null) { taskIds = java.util.Collections.emptySet(); }\nif (!taskIds.isEmpty()) { query.taskIds(taskIds); }","typeGuard":"boolean hasTaskIds(Set<String> s) { return s != null && !s.isEmpty(); }","tryCatchPattern":"try { query.taskIds(taskIds); } catch (org.activiti.engine.ActivitiIllegalArgumentException e) { throw new IllegalArgumentException(\"taskIds set must be non-null and non-empty\", e); }","preventionTips":["Initialize ID collections eagerly (new HashSet<>()) rather than leaving them null.","Prefer returning empty collections over null from DAOs (Collections.emptySet()).","Validate inputs at the API boundary before building queries."],"tags":["java","activiti","null-check","query-builder"],"backgroundTag":"null-argument","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"}