apache/beam · error · IllegalArgumentException

Could not parse the provided YAML stream into a non-trivial…

Error message

Could not parse the provided YAML stream into a non-trivial AllowList

What it means

Thrown when the YAML stream supplied to AllowList.parseFromYamlStream loads to null (empty stream, comments-only file, or a YAML root that is not a mapping), so no allowlist config Map can be constructed.

Solutions

  1. Verify the YAML file/stream is non-empty and its root is a mapping with keys like 'version' and 'allowedClasses'.
  2. Check the file path/resource actually exists and contains content; log the stream contents before parsing.
  3. If using templating/variable substitution, confirm the rendered output is valid non-empty YAML.

Example fix

# before (empty file)

# after
version: 1
allowedClasses:
  - className: org.apache.beam.sdk.transforms.MapElements
    allowedBuilderMethods: ['of']
Defensive patterns

Strategy: validation

Validate before calling

if (yamlText == null || yamlText.trim().isEmpty()) throw new IllegalArgumentException("AllowList YAML is empty");
Object root = new Yaml().load(new ByteArrayInputStream(yamlText.getBytes(StandardCharsets.UTF_8)));
if (!(root instanceof Map)) throw new IllegalArgumentException("AllowList YAML root must be a mapping");

Try / catch

try { AllowList list = AllowList.parseFromYamlStream(stream); } catch (IllegalArgumentException e) { log.error("Invalid allowlist YAML: {}", e.getMessage()); throw new ConfigException(e); }

Prevention

When it happens

Trigger: Calling parseFromYamlStream with an empty InputStream, a file containing only comments or 'null', or YAML whose root node is a scalar/list so yaml.load returns null or a non-Map treated as null.

Common situations: An empty or misnamed expansion-service allowlist YAML passed via config; a templated config rendered to nothing; wrong file path silently resolved to an empty resource.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/f152dd2d2d8e4c1d. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java:497

  public abstract static class AllowList {

    public static AllowList nothing() {
      return create(ALLOW_LIST_VERSION, Collections.emptyList());
    }

    public static AllowList everything() {
      return create(
          ALLOW_LIST_VERSION,
          Collections.singletonList(
              AllowedClass.create("*", AllowedClass.WILDCARD, AllowedClass.WILDCARD)));
    }

    static AllowList parseFromYamlStream(InputStream inputStream) {
      Yaml yaml = new Yaml();
      Map<Object, Object> config = yaml.load(inputStream);

      if (config == null) {
        throw new IllegalArgumentException(
            "Could not parse the provided YAML stream into a non-trivial AllowList");
      }

      String version = config.get("version") != null ? (String) config.get("version") : "";
      List<AllowedClass> allowedClasses = new ArrayList<>();
      if (config.get("allowedClasses") != null) {
        allowedClasses =
            ((List<Map<Object, Object>>) config.get("allowedClasses"))
                .stream()
                    .map(
                        data -> {
                          String className = (String) data.get("className");
                          if (className == null) {
                            throw new IllegalArgumentException(
                                "Expected each entry in the allowlist to include the 'className'");
                          }
                          List<String> allowedBuilderMethods =
                              (List<String>) data.get("allowedBuilderMethods");

View on GitHub (pinned to 12126d8942)