apache/beam · error · IllegalArgumentException
List of SerializableFunction must not be null
Error message
List of SerializableFunction must not be null
What it means
PAssert's PCollectionListContentsAssert.satisfies(List<SerializableFunction>) validates each checker function against the corresponding PCollection in the list. It throws this IllegalArgumentException immediately if the checker list is null, since there would be nothing to satisfy.
Solutions
- Pass a non-null List<SerializableFunction<Iterable<T>, Void>> with one checker per PCollection
- Initialize the list explicitly (e.g. Arrays.asList(checker1, checker2)) before calling satisfies
- If no checkers are needed, don't call satisfies at all rather than passing an empty/null list
Example fix
// before
List<SerializableFunction<Iterable<T>, Void>> checkers = null;
assertThat(list).satisfies(checkers);
// after
List<SerializableFunction<Iterable<T>, Void>> checkers =
Arrays.asList(input -> null, input -> null);
assertThat(list).satisfies(checkers); Defensive patterns
Strategy: validation
Validate before calling
Objects.requireNonNull(checkerFnList, "checkerFnList must not be null before satisfies(...)");
Type guard
boolean validCheckerList(List<?> checkers, PCollectionList<?> list) {
return checkers != null && checkers.size() == list.size();
} Try / catch
try {
assertThat(pcollectionList).satisfies(checkers);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("must not be null")) {
throw new IllegalStateException("Initialize the checker list before calling satisfies", e);
}
throw e;
} Prevention
- Never pass null checker lists; construct them explicitly with Arrays.asList(...)
- Validate list contents at the point of building test assertions
- Prefer individual PAssert.that(pcollection).satisfies(fn) calls when checkers are optional
When it happens
Trigger: Calling PAssert.that(pCollectionList).satisfies(null) — typically the result of a helper that builds checkers conditionally and returns null.
Common situations: Programmatic test-generation code that passes a null list of assertion functions; refactoring where individual satisfies(...) calls were consolidated and the list was never initialized.
Related errors
- If you meant to test object equality, use…
- List of SerializableFunction must be the same size as the…
- .hashCode() is not supported.
- tests for Java equality of the
- assert_that must be used within a beam.Pipeline context…
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/4b1683f777783f06.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java:620
public PCollectionListContentsAssert<T> satisfies(
SerializableFunction<Iterable<T>, Void> checkerFn) {
for (int i = 0; i < pCollectionList.size(); i++) {
PAssert.that(pCollectionList.get(i)).satisfies(checkerFn);
}
return this;
}
/**
* Takes list of {@link SerializableFunction}s of the same size as {@link #pCollectionList}, and
* applies each matcher to the {@code PCollection} with the identical index in the {@link
* #pCollectionList}.
*
* <p>Returns this {@code PCollectionListContentsAssert}.
*/
public PCollectionListContentsAssert<T> satisfies(
List<SerializableFunction<Iterable<T>, Void>> checkerFnList) {
if (checkerFnList == null) {
throw new IllegalArgumentException("List of SerializableFunction must not be null");
} else if (checkerFnList.size() != pCollectionList.size()) {
throw new IllegalArgumentException(
"List of SerializableFunction must be the same size as the PCollectionList");
}
for (int i = 0; i < pCollectionList.size(); i++) {
PAssert.that(pCollectionList.get(i)).satisfies(checkerFnList.get(i));
}
return this;
}
}
/**
* An {@link IterableAssert} about the contents of a {@link PCollection}. This does not require
* the runner to support side inputs.
*/
protected static class PCollectionContentsAssert<T> implements IterableAssert<T> {
private final PCollection<T> actual;
private final AssertionWindows rewindowingStrategy;View on GitHub (pinned to 12126d8942)