flowable/flowable-engine · error · FlowableIllegalArgumentException

searchKey2 is null

Error message

searchKey2 is null

What it means

BatchPartQueryImpl.searchKey2(String) filters batch parts by the secondary search key. Passing null throws FlowableIllegalArgumentException at the call site because a null filter is rejected rather than ignored. The check mirrors searchKey's validation.

Source

Thrown at modules/flowable-batch-service/src/main/java/org/flowable/batch/service/impl/BatchPartQueryImpl.java:103

            throw new FlowableIllegalArgumentException("type is null");
        }
        this.type = type;
        return this;
    }

    @Override
    public BatchPartQuery searchKey(String searchKey) {
        if (searchKey == null) {
            throw new FlowableIllegalArgumentException("searchKey is null");
        }
        this.searchKey = searchKey;
        return this;
    }

    @Override
    public BatchPartQuery searchKey2(String searchKey2) {
        if (searchKey2 == null) {
            throw new FlowableIllegalArgumentException("searchKey2 is null");
        }
        this.searchKey2 = searchKey2;
        return this;
    }

    @Override
    public BatchPartQuery batchType(String batchType) {
        if (batchType == null) {
            throw new FlowableIllegalArgumentException("batchType is null");
        }
        this.batchType = batchType;
        return this;
    }

    @Override
    public BatchPartQuery batchSearchKey(String searchKey) {
        if (searchKey == null) {
            throw new FlowableIllegalArgumentException("batchSearchKey is null");

View on GitHub (pinned to d6d39ce1c6)

Solutions

  1. Null-check the value before calling searchKey2(...).
  2. Apply the filter conditionally — skip searchKey2(...) when the value is null.
  3. If secondary key semantics require matching 'unset', query without the filter and post-filter results.

Example fix

// before
BatchPartQuery q = batchService.createBatchPartQuery().searchKey(k1).searchKey2(k2);
// after
BatchPartQuery q = batchService.createBatchPartQuery().searchKey(k1);
if (k2 != null) {
    q.searchKey2(k2);
}
Defensive patterns

Strategy: validation

Validate before calling

BatchPartQuery query = batchService.createBatchPartQuery().searchKey(k1);
if (k2 != null) {
    query.searchKey2(k2);
}
List<BatchPart> parts = query.list();

Type guard

boolean hasSearchKey2(String k) {
    return k != null && !k.isEmpty();
}

Try / catch

try {
    List<BatchPart> parts = query.searchKey2(searchKey2).list();
} catch (org.flowable.common.engine.api.FlowableIllegalArgumentException e) {
    throw new IllegalArgumentException("searchKey2 must not be null when filtering batch parts", e);
}

Prevention

When it happens

Trigger: Calling BatchPartQuery.searchKey2(null), typically when the second search key is optional upstream but passed unconditionally into the query.

Common situations: Treating searchKey2 as optional: callers assume the query builder accepts null like an empty list() would; batches created without searchKey2 then queried by it; form fields left blank.

Related errors


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