oscerd opened a new issue, #1861:
URL: https://github.com/apache/camel-kafka-connector/issues/1861

   ## Description
   
   When the body of a Camel message is a `java.util.Map` or a `java.util.List`, 
`CamelSourceTask` gives the record value a schema from 
`SchemaHelper.buildSchemaBuilderForType`. Unless `Values.inferSchema` can type 
every key and value, that schema is `new SchemaBuilder(Schema.Type.MAP)` or 
`new SchemaBuilder(Schema.Type.ARRAY)`, with no key or value schema. JSON 
objects with mixed value types are the common case, and for them inference 
fails.
   
   Kafka Connect's `JsonConverter` cannot serialize such a schema. Both 
`schemas.enable=true` and `schemas.enable=false` fail with:
   
   ```
   java.lang.NullPointerException: Cannot invoke 
"org.apache.kafka.connect.data.Schema.type()" because the return value of 
"org.apache.kafka.connect.data.Schema.keySchema()" is null
   ```
   
   `StringConverter` writes `Map.toString()` (for example `{token=abc, 
text=hello}`), which is not JSON.
   
   This affects every source connector whose route ends with a `Map` or `List` 
body. Examples:
   - the webhook source receiving `application/x-www-form-urlencoded` or 
multipart requests, whose fields arrive as a `Map`;
   - `camel.source.unmarshal=jackson` without a `marshal` back.
   
   ## Expected Behavior
   
   A `Map` or `List` record value can be written with the `JsonConverter`.
   
   ## Actual Behavior
   
   The task fails in the converter with the `NullPointerException` above.
   
   ## Proposed fix
   
   Send such values without a schema, which Kafka Connect supports. 
`JsonConverter` then writes the JSON object or array with either 
`schemas.enable` setting.
   
   ---
   _Claude Code on behalf of Andrea Cosentino_
   


-- 
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]

Reply via email to