{"record":{"id":"4b1683f777783f06","repo":"apache/beam","slug":"list-of-serializablefunction-must-not-be-null","errorCode":null,"errorMessage":"List of SerializableFunction must not be null","messagePattern":"List of SerializableFunction must not be null","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java","lineNumber":620,"sourceCode":"    public PCollectionListContentsAssert<T> satisfies(\n        SerializableFunction<Iterable<T>, Void> checkerFn) {\n      for (int i = 0; i < pCollectionList.size(); i++) {\n        PAssert.that(pCollectionList.get(i)).satisfies(checkerFn);\n      }\n      return this;\n    }\n\n    /**\n     * Takes list of {@link SerializableFunction}s of the same size as {@link #pCollectionList}, and\n     * applies each matcher to the {@code PCollection} with the identical index in the {@link\n     * #pCollectionList}.\n     *\n     * <p>Returns this {@code PCollectionListContentsAssert}.\n     */\n    public PCollectionListContentsAssert<T> satisfies(\n        List<SerializableFunction<Iterable<T>, Void>> checkerFnList) {\n      if (checkerFnList == null) {\n        throw new IllegalArgumentException(\"List of SerializableFunction must not be null\");\n      } else if (checkerFnList.size() != pCollectionList.size()) {\n        throw new IllegalArgumentException(\n            \"List of SerializableFunction must be the same size as the PCollectionList\");\n      }\n      for (int i = 0; i < pCollectionList.size(); i++) {\n        PAssert.that(pCollectionList.get(i)).satisfies(checkerFnList.get(i));\n      }\n      return this;\n    }\n  }\n\n  /**\n   * An {@link IterableAssert} about the contents of a {@link PCollection}. This does not require\n   * the runner to support side inputs.\n   */\n  protected static class PCollectionContentsAssert<T> implements IterableAssert<T> {\n    private final PCollection<T> actual;\n    private final AssertionWindows rewindowingStrategy;","sourceCodeStart":602,"sourceCodeEnd":638,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/testing/PAssert.java#L602-L638","documentation":"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.","triggerScenarios":"Calling PAssert.that(pCollectionList).satisfies(null) — typically the result of a helper that builds checkers conditionally and returns null.","commonSituations":"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.","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"],"exampleFix":"// before\nList<SerializableFunction<Iterable<T>, Void>> checkers = null;\nassertThat(list).satisfies(checkers);\n// after\nList<SerializableFunction<Iterable<T>, Void>> checkers =\n    Arrays.asList(input -> null, input -> null);\nassertThat(list).satisfies(checkers);","handlingStrategy":"validation","validationCode":"Objects.requireNonNull(checkerFnList, \"checkerFnList must not be null before satisfies(...)\");","typeGuard":"boolean validCheckerList(List<?> checkers, PCollectionList<?> list) {\n  return checkers != null && checkers.size() == list.size();\n}","tryCatchPattern":"try {\n  assertThat(pcollectionList).satisfies(checkers);\n} catch (IllegalArgumentException e) {\n  if (e.getMessage().contains(\"must not be null\")) {\n    throw new IllegalStateException(\"Initialize the checker list before calling satisfies\", e);\n  }\n  throw e;\n}","preventionTips":["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"],"tags":["apache-beam","passert","null-check","testing"],"backgroundTag":"null-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}