You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "Peter Turcsanyi (Jira)" <ji...@apache.org> on 2021/03/01 15:30:00 UTC
[jira] [Updated] (NIFI-7969) XMLReader / ValidateRecord: arrays are
not read correctly
[ https://issues.apache.org/jira/browse/NIFI-7969?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Peter Turcsanyi updated NIFI-7969:
----------------------------------
Fix Version/s: 1.14.0
Resolution: Fixed
Status: Resolved (was: Patch Available)
> XMLReader / ValidateRecord: arrays are not read correctly
> ---------------------------------------------------------
>
> Key: NIFI-7969
> URL: https://issues.apache.org/jira/browse/NIFI-7969
> Project: Apache NiFi
> Issue Type: Bug
> Components: Core Framework, Extensions
> Affects Versions: 1.9.0, 1.12.0
> Reporter: Vesa Sokka
> Assignee: Peter Gyori
> Priority: Major
> Labels: records, validation, xml
> Fix For: 1.14.0
>
> Attachments: image-2020-10-30-13-09-08-833.png, xml_array.xml
>
> Time Spent: 1h
> Remaining Estimate: 0h
>
> I'm trying to convert XML to JSON with ValidateRecord using XMLReader. Arrays with multiple elements work fine, but an *array with only one element fails*.
>
> In XMLReader docs it says clearly:
> _"If a field in a schema is embedded in an array, the *reader expects zero, one or more* occurrences of the field in a record. "_
> But in fact an array with only one field is transferred to "invalid" with an error message:
> "Record #1 is invalid due to:
> content1 is not a valid value for /array_field: Value is of type java.lang.String but was expected to be of type ARRAY[STRING]"
>
> examples modified from:
> [https://nifi.apache.org/docs/nifi-docs/components/org.apache.nifi/nifi-record-serialization-services-nar/1.12.1/org.apache.nifi.xml.XMLReader/additionalDetails.]
> !image-2020-10-30-13-09-08-833.png|height=250!
> _Both examples have same schema_;
> {code:json}
> {
> "namespace": "nifi",
> "name": "test",
> "type": "record",
> "fields": [
> { "name": "array_field",
> "type":
> { "type": "array", "items": "string" }
> }
> ]
> }
> {code}
>
>
> *Example 1* (success)
> {code:xml}
> <record>
> <array_field>content1</array_field>
> <array_field>content2</array_field>
> </record> {code}
> --> *valid*+:+
> {code:json}
> [{"array_field":["content1","content2"]}]
> {code}
>
> *Example 2* (invalid):
> Same as example 1, but the second array_field removed
> {code:xml}
> <record>
> <array_field>content1</array_field>
> </record>
> {code}
> --> *invalid*
> {code:json}
> [{"array_field":"content1"}]{code}
>
>
> *Seems to be a BUG or is this an error in the processor documentation?*
>
> Template attached:
> xml_array.xml
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)