Uploaded image for project: 'Apache NiFi'
  1. Apache NiFi
  2. NIFI-7925

ValidateRecord reports false positive for avro arrays with null elements

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.12.1
    • 1.13.0
    • None
    • None

    Description

      with this avro schema:

      {
          "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": ""
          }
          ]
      }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              denes Denes Arvay
              kpnc Christophe Monnet
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h