[ 
https://issues.apache.org/jira/browse/NIFI-16660?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Stieglitz reassigned NIFI-16660:
---------------------------------------

    Assignee: Daniel Stieglitz

> AvroTypeUtil fails to convert schema with union [array, "null"] and empty 
> array default []
> ------------------------------------------------------------------------------------------
>
>                 Key: NIFI-16660
>                 URL: https://issues.apache.org/jira/browse/NIFI-16660
>             Project: Apache NiFi
>          Issue Type: Bug
>    Affects Versions: 2.9.0
>            Reporter: Janis Ax
>            Assignee: Daniel Stieglitz
>            Priority: Major
>
> I am facing the following problem with sending messages from nifi to Kafka 
> using the Confluent AVRO Schema registry.
> When an Avro schema contains a field of type union [array, "null"] with a 
> default value of [] (valid according to the Avro specification, since the 
> default must match the first type of the union), NiFi fails to convert the 
> Avro schema into a NiFi RecordSchema.
> The same schema is accepted by the Confluent Schema Registry and by non-NiFi 
> producers (Confluent Avro Serializer) without any issues.
> Steps to reproduce
> Register the following schema in a Confluent Schema Registry (or use it as 
> Schema Text / in AvroSchemaRegistry):
> {code:json}
> {
> "type": "record",
> "name": "Example",
> "namespace": "test",
> "fields": [
> {
> "name": "M_Manufacturer",
> "type": [ { "type": "array", "items": "string" }, "null" ],
> "default": []
> }
> ]
> }
> {code}
> Configure an AvroRecordSetWriter with Schema Access Strategy "Use 
> 'SchemaName' Property" (ConfluentSchemaRegistry) or "Use 'Schema Text' 
> Property".
> Process a JSON record, e.g. {"M_Manufacturer": ["NORD"]}, with ConvertRecord 
> or PublishKafka.
> Actual result
> {code}
> org.apache.nifi.schema.access.SchemaNotFoundException: Could not retrieve s=
> chema with name '...' from the configured Schema Registry
> Caused by: java.lang.IllegalArgumentException: Cannot set the default val=
> ue for field [M_Manufacturer] to [[]] because that is not a valid value for=
> Data Type [ARRAY[STRING]]
> {code}
> Expected result
> The schema is converted successfully and the record is written. An empty li=
> st default should be accepted for an array type inside a union.
> Environment
> NiFi 2.9.0 (Stackable distribution), Kafka3ConnectionService, Confluent Clo=
> ud Schema Registry, ConfluentEncodedSchemaReferenceWriter.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to