flowable/flowable-engine · error · ActivitiIllegalArgumentException

None of the given process instance ids can be null

Error message

None of the given process instance ids can be null

What it means

HistoricTaskInstanceQueryImpl.processInstanceIdIn() throws ActivitiIllegalArgumentException when any element of the supplied process instance id list is null. The list is rendered into an SQL IN clause, where null elements are not permitted. Remove null entries or fix the code producing them.

Solutions

  1. Filter nulls out of the list before calling: ids.removeIf(Objects::isNull).
  2. Fix the upstream source that inserts null ids into the collection.
  3. Use Objects.requireNonNull on each id at collection time to fail fast at the source.

Example fix

// before
query.processInstanceIdIn(ids); // ids contains nulls

// after
List<String> cleanIds = ids.stream().filter(Objects::nonNull).collect(Collectors.toList());
if (!cleanIds.isEmpty()) {
    query.processInstanceIdIn(cleanIds);
}
Defensive patterns

Strategy: validation

Validate before calling

List<String> clean = ids == null ? Collections.emptyList() : ids.stream().filter(Objects::nonNull).collect(Collectors.toList());
if (clean.isEmpty()) { throw new IllegalArgumentException("need at least one non-null process instance id"); }

Type guard

static boolean hasNoNulls(List<String> list) { return list != null && list.stream().allMatch(Objects::nonNull); }

Try / catch

try {
    query.processInstanceIdIn(ids);
} catch (org.activiti.engine.ActivitiIllegalArgumentException e) {
    throw new IllegalArgumentException("Bad process instance id list: " + e.getMessage(), e);
}

Prevention

When it happens

Trigger: Calling historicTaskInstanceQuery.processInstanceIdIn(Arrays.asList("id1", null)) or any List<String> containing a null element.

Common situations: Collecting ids from a map/dataset with missing keys; deserializing a JSON array containing nulls; list built from optional lookups that returned null instead of skipping.

Related errors


AI-assisted analysis of flowable/flowable-engine@d6d39ce1c6 (2026-09-11). Data as JSON: /api/errors/267c8674f945b5e1. Report an issue: GitHub.

Appendix: source

Thrown at modules/flowable5-engine/src/main/java/org/activiti/engine/impl/HistoricTaskInstanceQueryImpl.java:169

        if (inOrStatement) {
            this.currentOrQueryObject.processInstanceId = processInstanceId;
        } else {
            this.processInstanceId = processInstanceId;
        }
        return this;
    }

    @Override
    public HistoricTaskInstanceQueryImpl processInstanceIdIn(List<String> processInstanceIds) {
        if (processInstanceIds == null) {
            throw new ActivitiIllegalArgumentException("Process instance id list is null");
        }
        if (processInstanceIds.isEmpty()) {
            throw new ActivitiIllegalArgumentException("Process instance id list is empty");
        }
        for (String processInstanceId : processInstanceIds) {
            if (processInstanceId == null) {
                throw new ActivitiIllegalArgumentException("None of the given process instance ids can be null");
            }
        }

        if (inOrStatement) {
            this.currentOrQueryObject.processInstanceIds = processInstanceIds;
        } else {
            this.processInstanceIds = processInstanceIds;
        }
        return this;
    }

    @Override
    public HistoricTaskInstanceQueryImpl processInstanceBusinessKey(String processInstanceBusinessKey) {
        if (inOrStatement) {
            this.currentOrQueryObject.processInstanceBusinessKey = processInstanceBusinessKey;
        } else {
            this.processInstanceBusinessKey = processInstanceBusinessKey;
        }

View on GitHub (pinned to d6d39ce1c6)