Given a schema with a field that is a union of string and an enum, we can do a serialization/deserialization without issue. If, however, the same schema has a rule applied the serialization fails, even if the rule is not related to the field.
The test code below illustrates the issue (modeled from existing avro tests for the schemaregistry). The test without a rule is successful. The test with a rule fails:
Error: invalid ["string",{"name":"test.Color","type":"enum","symbols":["RED","BLUE"]}]: null
at throwInvalidError (/Users/peloquina/src/github/confluent-kafka-javascript/node_modules/avsc/lib/types.js:3042:9)
at WrappedUnionType.Object.<anonymous>.WrappedUnionType._write (/Users/peloquina/src/github/confluent-kafka-javascript/node_modules/avsc/lib/types.js:1498:7)
at RecordType.writeUnionTest [as _write] (eval at Object.<anonymous>.RecordType._createWriter (/Users/peloquina/src/github/confluent-kafka-javascript/node_modules/avsc/lib/types.js:2343:10), <anonymous>:8:8)
at RecordType.Object.<anonymous>.Type.toBuffer (/Users/peloquina/src/github/confluent-kafka-javascript/node_modules/avsc/lib/types.js:658:8)
at AvroSerializer.serialize (/Users/peloquina/src/github/confluent-kafka-javascript/schemaregistry/dist/serde/avro.js:85:37)
This issue was found while trying to track down a similar issue with deserialization. In that case the serialization happened on a partner service with the Java client, using the same schema of course. In that scenario, the field was deserializing as a null even though the source had a value. We were unable to replicate that issue in a standalone test due to this issue. Seems likely the two are related.
Environment Information
Steps to Reproduce
Given a schema with a field that is a union of string and an enum, we can do a serialization/deserialization without issue. If, however, the same schema has a rule applied the serialization fails, even if the rule is not related to the field.
The test code below illustrates the issue (modeled from existing avro tests for the schemaregistry). The test without a rule is successful. The test with a rule fails:
This issue was found while trying to track down a similar issue with deserialization. In that case the serialization happened on a partner service with the Java client, using the same schema of course. In that scenario, the field was deserializing as a null even though the source had a value. We were unable to replicate that issue in a standalone test due to this issue. Seems likely the two are related.