apache/beam · error · java.lang.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 ExpansionServiceConfig

What it means

Thrown by ExpansionServiceConfig.parseFromYamlStream when the YAML input deserializes to null — meaning the stream was empty or contained only comments/whitespace — so no non-trivial ExpansionServiceConfig can be built. The service requires at least a mapping node to read allowlist/dependency entries from.

Solutions

  1. Add valid content to the YAML file, e.g. an allowlist mapping: 'allowlist: ["org.apache.beam.sdk.transforms.*"]'.
  2. Point --expansionServiceConfigFile at the correct, non-empty file.
  3. Check the file with 'cat' (or 'wc -c') to confirm it has content before starting the service.

Example fix

// before: config.yaml is empty
// after: config.yaml
allowlist:
  - "org.apache.beam.sdk.schemas.transforms.*"
dependencies: {}
Defensive patterns

Strategy: validation

Validate before calling

File f = new File(configPath);
if (!f.exists() || f.length() == 0) {
  throw new IllegalStateException("Expansion service config file is missing or empty: " + configPath);
}

Try / catch

try {
  cfg = ExpansionServiceConfig.parseFromYamlStream(stream);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("non-trivial")) { /* supply a non-empty YAML mapping */ }
  throw e;
}

Prevention

When it happens

Trigger: Passing an empty file, an empty InputStream, or a YAML file containing only comments to parseFromYamlStream, or wiring the config-file provider at a path that resolves to a zero-byte file.

Common situations: Config file created but never populated; wrong file mounted in a container so the target path is empty; redirection created an empty file (e.g. 'touch config.yaml').

Related errors


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

Appendix: source

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

  public static ExpansionServiceConfig empty() {
    return create(new ArrayList<>(), new HashMap<>());
  }

  public static ExpansionServiceConfig create(
      List<String> allowlist, Map<String, List<Dependency>> dependencies) {
    if (allowlist == null) {
      allowlist = new ArrayList<>();
    }
    return new AutoValue_ExpansionServiceConfig(allowlist, dependencies);
  }

  static ExpansionServiceConfig 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 ExpansionServiceConfig");
    }

    List<String> allowList = new ArrayList<>();
    Map<String, List<Dependency>> dependencies = new HashMap<>();
    if (config.get("allowlist") != null) {
      allowList = (List<String>) config.get("allowlist");
    }

    if (config.get("dependencies") != null) {
      Map<String, List<Object>> dependenciesFromConfig =
          (Map<String, List<Object>>) config.get("dependencies");
      dependenciesFromConfig.forEach(
          (k, v) -> {
            if (v != null) {
              List<Dependency> dependenciesForTransform =
                  v.stream()
                      .map(

View on GitHub (pinned to 12126d8942)