{"record":{"id":"f152dd2d2d8e4c1d","repo":"apache/beam","slug":"could-not-parse-the-provided-yaml-stream-into-a-non-trivial-f152dd","errorCode":null,"errorMessage":"Could not parse the provided YAML stream into a non-trivial AllowList","messagePattern":"Could not parse the provided YAML stream into a non-trivial AllowList","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java","lineNumber":497,"sourceCode":"  public abstract static class AllowList {\n\n    public static AllowList nothing() {\n      return create(ALLOW_LIST_VERSION, Collections.emptyList());\n    }\n\n    public static AllowList everything() {\n      return create(\n          ALLOW_LIST_VERSION,\n          Collections.singletonList(\n              AllowedClass.create(\"*\", AllowedClass.WILDCARD, AllowedClass.WILDCARD)));\n    }\n\n    static AllowList parseFromYamlStream(InputStream inputStream) {\n      Yaml yaml = new Yaml();\n      Map<Object, Object> config = yaml.load(inputStream);\n\n      if (config == null) {\n        throw new IllegalArgumentException(\n            \"Could not parse the provided YAML stream into a non-trivial AllowList\");\n      }\n\n      String version = config.get(\"version\") != null ? (String) config.get(\"version\") : \"\";\n      List<AllowedClass> allowedClasses = new ArrayList<>();\n      if (config.get(\"allowedClasses\") != null) {\n        allowedClasses =\n            ((List<Map<Object, Object>>) config.get(\"allowedClasses\"))\n                .stream()\n                    .map(\n                        data -> {\n                          String className = (String) data.get(\"className\");\n                          if (className == null) {\n                            throw new IllegalArgumentException(\n                                \"Expected each entry in the allowlist to include the 'className'\");\n                          }\n                          List<String> allowedBuilderMethods =\n                              (List<String>) data.get(\"allowedBuilderMethods\");","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/expansion-service/src/main/java/org/apache/beam/sdk/expansion/service/JavaClassLookupTransformProvider.java#L479-L515","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Verify the YAML file/stream is non-empty and its root is a mapping with keys like 'version' and 'allowedClasses'.","Check the file path/resource actually exists and contains content; log the stream contents before parsing.","If using templating/variable substitution, confirm the rendered output is valid non-empty YAML."],"exampleFix":"# before (empty file)\n\n# after\nversion: 1\nallowedClasses:\n  - className: org.apache.beam.sdk.transforms.MapElements\n    allowedBuilderMethods: ['of']","handlingStrategy":"validation","validationCode":"if (yamlText == null || yamlText.trim().isEmpty()) throw new IllegalArgumentException(\"AllowList YAML is empty\");\nObject root = new Yaml().load(new ByteArrayInputStream(yamlText.getBytes(StandardCharsets.UTF_8)));\nif (!(root instanceof Map)) throw new IllegalArgumentException(\"AllowList YAML root must be a mapping\");","typeGuard":null,"tryCatchPattern":"try { AllowList list = AllowList.parseFromYamlStream(stream); } catch (IllegalArgumentException e) { log.error(\"Invalid allowlist YAML: {}\", e.getMessage()); throw new ConfigException(e); }","preventionTips":["Ship a non-empty allowlist YAML with at least 'version' and 'allowedClasses' keys","Validate YAML in CI before deploying the expansion service","Log the parsed config map after load for auditability","Never point the service at a placeholder/empty file"],"tags":["yaml","configuration","expansion-service"],"backgroundTag":"yaml-parse-error","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"}