Tanishq-Choudhary opened a new issue, #41532:
URL: https://github.com/apache/beam/issues/41532

   ### What happened?
   
   `YamlUtils.toBeamRow` converts YAML scalars to the field type for top-level 
fields and list elements, but returns MAP values as they came from SnakeYAML. 
So a `map<str, str>` config field such as Kafka's `consumer_config_updates` or 
Iceberg's `catalog_properties` gets an `Integer` or `Boolean` when the value 
isn't quoted, and building the Row fails.
   
   Repro on master (35dbffbb), Java 21:
   
   ```java
   Pipeline p = Pipeline.create();
   PCollectionRowTuple.empty(p)
       .apply(
           Managed.read(Managed.KAFKA)
               .withConfig(
                   YamlUtils.yamlStringToMap(
                       "topic: orders\n"
                           + "bootstrap_servers: localhost:9092\n"
                           + "format: RAW\n"
                           + "consumer_config_updates:\n"
                           + "  max.poll.records: 500\n"
                           + "  enable.auto.commit: false\n")));
   ```
   
   Actual:
   
   ```
   java.lang.IllegalArgumentException: Encountered an error when retrieving a 
configuration
     at 
org.apache.beam.sdk.managed.ManagedSchemaTransformProvider$ManagedSchemaTransform.<init>(ManagedSchemaTransformProvider.java:168)
     ...
   Caused by:
   java.lang.ClassCastException: class java.lang.Integer cannot be cast to 
class java.lang.String
   ```
   
   Expected: the values become "500" and "false", the same way `topic: 123` 
already becomes "123" for a string field.
   
   `withConfig(Map.of("consumer_config_updates", Map.of("max.poll.records", 
500)))` fails the same way, since the map goes through YAML first. Python 
`managed.Read(..., config=...)` sends its config as a YAML string to the same 
code (I didn't run that one).
   
   Root cause: the MAP branch in `YamlUtils.toBeamValue` is `return 
yamlValue;`. The ROW and List branches already recurse with the nested field 
type.
   
   Workaround: quote the values (`max.poll.records: "500"`).
   
   Not the same as #35186 / #40023, which handled a map or list going into a 
STRING field.
   
   ### Issue Priority
   
   Priority: 2 (default / most bugs should be filed as P2)
   
   ### Issue Components
   
   - [ ] Component: Python SDK
   - [x] Component: Java SDK
   - [ ] Component: Go SDK
   - [ ] Component: Typescript SDK
   - [x] Component: IO connector
   - [ ] Component: Beam YAML
   - [ ] Component: Beam examples
   - [ ] Component: Beam playground
   - [ ] Component: Beam katas
   - [ ] Component: Website
   - [ ] Component: Infrastructure
   - [ ] Component: Spark Runner
   - [ ] Component: Flink Runner
   - [ ] Component: Prism Runner
   - [ ] Component: Hazelcast Jet Runner
   - [ ] Component: Google Cloud Dataflow Runner


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

  • [I] [Bug]: Managed config fails ... Tanishq-Choudhary (via GitHub) via github

Reply via email to