[
https://issues.apache.org/jira/browse/NIFI-7925?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Christophe Monnet updated NIFI-7925:
------------------------------------
Description:
with this avro schema:
{code:json}
{
"type": "record",
"name": "simple",
"fields": [{
"name": "stuff",
"type": {
"type": "record",
"name": "stuff",
"namespace": "simple",
"fields": [{
"name": "languages",
"type": {
"type": "array",
"items": ["null", "string"]
},
"doc": ""
}
]
},
"doc": ""
}
]
}
{code}
and this payload:
{code:json}
{"stuff":{"languages":[null]}}
{code}
ValidateRecord fails with
Records in this FlowFile were invalid for the following reasons: ; The
following 1 fields had values whose type did not match the schema:
[/stuff/languages]
But when using avrotool I can convert the payload:
{code:bash}
$ avrotool fromjson --schema-file schema.json payload.json > payload.avro
$ avrotool tojson payload.avro
{"stuff":{"languages":[null]}}
{code}
Moreover with this payload
{code:json}
{"stuff":{"languages":[]}}
{code}
ValidateRecord routes to the valid queue.
Therefore I suspect that ValidateRecord has a bug when it comes to arrays with
nullable items.
was:
with this avro schema:
{code:json}
{
"type": "record",
"name": "simple",
"fields": [{
"name": "stuff",
"type": {
"type": "record",
"name": "stuff",
"namespace": "simple",
"fields": [{
"name": "languages",
"type": {
"type": "array",
"items": ["null", "string"]
},
"doc": ""
}
]
},
"doc": ""
}
]
}
{code}
and this payload:
{"stuff":{"languages":[null]}}
ValidateRecord fails with
Records in this FlowFile were invalid for the following reasons: ; The
following 1 fields had values whose type did not match the schema:
[/stuff/languages]
But when using avrotool I can convert the payload:
$ avrotool fromjson --schema-file schema.json payload.json > payload.avro
$ avrotool tojson payload.avro
{"stuff":{"languages":[null]}}
Moreover with this payload
{"stuff":{"languages":[]}}
ValidateRecord routes to the valid queue.
Therefore I suspect that ValidateRecord has a bug when it comes to arrays with
nullable items.
> ValidateRecord reports false positive for avro arrays with null elements
> ------------------------------------------------------------------------
>
> Key: NIFI-7925
> URL: https://issues.apache.org/jira/browse/NIFI-7925
> Project: Apache NiFi
> Issue Type: Bug
> Affects Versions: 1.12.1
> Reporter: Christophe Monnet
> Priority: Major
>
> with this avro schema:
> {code:json}
> {
> "type": "record",
> "name": "simple",
> "fields": [{
> "name": "stuff",
> "type": {
> "type": "record",
> "name": "stuff",
> "namespace": "simple",
> "fields": [{
> "name": "languages",
> "type": {
> "type": "array",
> "items": ["null", "string"]
> },
> "doc": ""
> }
> ]
> },
> "doc": ""
> }
> ]
> }
> {code}
> and this payload:
> {code:json}
> {"stuff":{"languages":[null]}}
> {code}
> ValidateRecord fails with
> Records in this FlowFile were invalid for the following reasons: ; The
> following 1 fields had values whose type did not match the schema:
> [/stuff/languages]
> But when using avrotool I can convert the payload:
> {code:bash}
> $ avrotool fromjson --schema-file schema.json payload.json > payload.avro
> $ avrotool tojson payload.avro
> {"stuff":{"languages":[null]}}
> {code}
> Moreover with this payload
> {code:json}
> {"stuff":{"languages":[]}}
> {code}
> ValidateRecord routes to the valid queue.
> Therefore I suspect that ValidateRecord has a bug when it comes to arrays
> with nullable items.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)