apache/beam · error · IllegalArgumentException
List of SerializableFunction must be the same size as the…
Error message
List of SerializableFunction must be the same size as the PCollectionList
What it means
PAssert's PCollectionListContentsAssert.satisfies(List<SerializableFunction>) requires one checker function per PCollection in the list. When the list of checkers has a different size than the PCollectionList, it throws this IllegalArgumentException, because there would be no defined pairing between checkers and collections.
Solutions
- Provide exactly one SerializableFunction per PCollection in the PCollectionList, in order
- Derive the checker list from the PCollectionList itself so sizes can't diverge
- Assert each PCollection separately with PAssert.that(pcollection).satisfies(...) instead of the list variant
Example fix
// before assertThat(list).satisfies(Collections.singletonList(checker)); // list has 2 PCollections // after assertThat(list).satisfies(Arrays.asList(checker1, checker2));
Defensive patterns
Strategy: validation
Validate before calling
if (checkerFnList.size() != pcollectionList.size()) {
throw new IllegalStateException("Need " + pcollectionList.size() + " checkers, got " + checkerFnList.size());
} Type guard
boolean checkersMatchList(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("same size as the PCollectionList")) {
throw new IllegalStateException("Add/remove checkers to match PCollectionList size", e);
}
throw e;
} Prevention
- Generate the checker list from the same code that builds the PCollectionList so sizes stay in sync
- Update checker lists whenever the pipeline adds PCollections to the list
- Prefer per-PCollection PAssert.that(...).satisfies(...) for lists that change shape
When it happens
Trigger: Calling PAssert.that(pcollectionList).satisfies(checkers) where checkers.size() != pcollectionList.size() — e.g. building checkers for a subset of PCollections, or the PCollectionList gains an element while the checker list does not.
Common situations: Tests whose pipeline is modified to add another PCollection to the list but whose checker list wasn't updated; dynamically generated lists where counts drift.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- If you meant to test object equality, use…
- List of SerializableFunction must not be null
- .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/665dbd174b19ed68.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java:622
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;
private final SimpleFunction<Iterable<ValueInSingleWindow<T>>, Iterable<T>> paneExtractor;
private final PAssertionSite site;View on GitHub (pinned to 12126d8942)