{"record":{"id":"b5fbe0449d9958aa","repo":"flowable/flowable-engine","slug":"taskid-is-empty","errorCode":null,"errorMessage":"taskId is empty","messagePattern":"taskId is empty","errorType":"validation","errorClass":"org.flowable.common.engine.api.FlowableIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java","lineNumber":68,"sourceCode":"    protected boolean withoutSubScopeId;\n    protected String scopeType;\n    protected Collection<String> scopeTypes;\n    protected String name;\n    protected Collection<String> names;\n\n    @Override\n    public InternalVariableInstanceQuery id(String id) {\n        if (StringUtils.isEmpty(id)) {\n            throw new FlowableIllegalArgumentException(\"id is empty\");\n        }\n        this.id = id;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery taskId(String taskId) {\n        if (StringUtils.isEmpty(taskId)) {\n            throw new FlowableIllegalArgumentException(\"taskId is empty\");\n        }\n\n        if (withoutTaskId) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine taskId(String) with withoutTaskId() in the same query\");\n        }\n\n        this.taskId = taskId;\n        return this;\n    }\n\n    @Override\n    public InternalVariableInstanceQuery taskIds(Collection<String> taskIds) {\n        if (taskIds == null || taskIds.isEmpty()) {\n            throw new FlowableIllegalArgumentException(\"taskIds is null or empty\");\n        }\n\n        if (withoutTaskId) {\n            throw new FlowableIllegalArgumentException(\"Cannot combine taskIds(Collection) with withoutTaskId() in the same query\");","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/flowable/flowable-engine/blob/d6d39ce1c69ff244f2d9dc6af756a9b95e865586/modules/flowable-variable-service/src/main/java/org/flowable/variable/service/impl/InternalVariableInstanceQueryImpl.java#L50-L86","documentation":"InternalVariableInstanceQueryImpl.taskId(String) throws FlowableIllegalArgumentException when the given taskId is null or an empty string. The variable-instance query API requires a non-empty task id to filter variables by task; passing blank input would produce a broken or full-table query, so the builder rejects it eagerly. This fail-fast validation happens at query-construction time, before any database access.","triggerScenarios":"Calling internalVariableInstanceQuery taskId(null) or taskId(\"\") — e.g. a task id variable that was never initialized, or a value derived from an empty JSON/HTTP field.","commonSituations":"Task id fetched from an upstream API or form field that is blank; refactor left the id unset; whitespace-only strings (StringUtils.isEmpty treats only null and \"\" as empty, so \" \" passes and may return no results).","solutions":["Ensure a non-empty task id is resolved before building the query","Check the upstream source of the task id for empty/blank values","If the goal is 'variables not tied to a task', call withoutTaskId() instead of passing an empty id"],"exampleFix":"// before\nquery.taskId(task.getId()); // NPE/empty when task not yet persisted\n// after\nif (task != null && task.getId() != null) {\n    query.taskId(task.getId());\n} else {\n    query.withoutTaskId();\n}","handlingStrategy":"validation","validationCode":"if (taskId == null || taskId.isEmpty()) { throw new IllegalArgumentException(\"taskId must be non-empty before querying\"); }","typeGuard":"boolean hasTaskId(String id) { return id != null && !id.isEmpty(); }","tryCatchPattern":"try { query.taskId(taskId); } catch (FlowableIllegalArgumentException e) { log.warn(\"Invalid taskId for variable query\", e); return Collections.emptyList(); }","preventionTips":["Validate ids at the service boundary before building queries","Never pass ids derived from unvalidated request input directly into Flowable queries","Remember StringUtils.isEmpty does not trim; trim/blank-check manually if whitespace matters"],"tags":["flowable","query-builder","argument-validation","null-argument"],"backgroundTag":"empty-required-field","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"}