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 TransformServiceConfig

What it means

Thrown by TransformServiceConfig.parseFromYamlStream when the YAML stream deserializes to null — i.e. the file parsed as YAML but contained no meaningful mapping. A TransformServiceConfig must be a non-empty mapping (at minimum an 'expansionservices' key).

Solutions

  1. Add content to the YAML file, starting with an 'expansionservices' list.
  2. Check the file was not truncated — verify with 'cat' that it holds the full config.
  3. Ensure you are pointing at the intended config file path.

Example fix

// before: empty config file
# my service config (nothing else)
// after: valid config file
expansionservices:
  - "localhost:12345"
Defensive patterns

Strategy: validation

Validate before calling

import org.yaml.snakeyaml.Yaml;
static void validateConfigYaml(String path) throws IOException {
  try (InputStream in = new FileInputStream(path)) {
    Object parsed = new Yaml().load(in);
    if (!(parsed instanceof Map) || ((Map<?, ?>) parsed).isEmpty()) {
      throw new IllegalArgumentException(path + " is empty or not a YAML mapping");
    }
  }
}

Type guard

boolean isNonEmptyYamlMapping(InputStream in) {
  Object o = new Yaml().load(in);
  return o instanceof Map && !((Map<?, ?>) o).isEmpty();
}

Try / catch

try {
  config = TransformServiceConfig.parseFromYamlStream(stream);
} catch (IllegalArgumentException e) {
  if (e.getMessage().contains("non-trivial TransformServiceConfig")) {
    throw new IllegalArgumentException("Config file is empty; add an 'expansionservices' section.", e);
  }
  throw e;
}

Prevention

When it happens

Trigger: Passing an InputStream whose content is empty, only comments, only whitespace, or a YAML document consisting solely of 'null' to parseFromYamlStream (directly or via a config file provided through TransformServiceOptions).

Common situations: Config file created but left empty; file contains only comments ('# ...'); YAML was truncated or the wrong file was passed.

Related errors


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

Appendix: source

Thrown at sdks/java/transform-service/src/main/java/org/apache/beam/sdk/transformservice/TransformServiceConfig.java:47

  public abstract List<String> getExpansionservices();

  public static TransformServiceConfig empty() {
    return create(new ArrayList<>());
  }

  static TransformServiceConfig create(List<String> expansionservices) {
    if (expansionservices == null) {
      expansionservices = new ArrayList<>();
    }

    return new AutoValue_TransformServiceConfig(expansionservices);
  }

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

    List<String> expansionservices = null;
    if (config.get("expansionservices") != null) {
      expansionservices = (List<String>) config.get("expansionservices");
    }

    if (expansionservices == null) {
      throw new IllegalArgumentException(
          "Expected the Transform Service config to contain at least one Expansion Service.");
    }

    return TransformServiceConfig.create(expansionservices);
  }
}

View on GitHub (pinned to 12126d8942)