title: Conversion of JSON to Avro failed: Failed to convert JSON to Avro: Unknown union branch
body: <p>I am trying to send a JSON message to a Kafka topic using Kafka-rest service to serialize JSON as an Avro object, but the JSON message is failed to get accepted by Kafka-rest with the following error:</p>
  
  <pre><code>Conversion of JSON to Avro failed: Failed to convert JSON to Avro: Unknown union branch postId
  </code></pre>
  
  <p>I suspect that there is an issue with the Avro schema I am using as it is a nested record type with nullable fields.</p>
  
  <p>Avro schema:</p>
  
  <pre><code>{
    "type": "record",
    "name": "ExportRequest",
    "namespace": "com.example.avro.model",
    "fields": [
      {
        "name": "context",
        "type": {
          "type": "map",
          "values": {
            "type": "string",
            "avro.java.string": "String"
          },
          "avro.java.string": "String"
        }
      },
      {
        "name": "exportInfo",
        "type": {
          "type": "record",
          "name": "ExportInfo",
          "fields": [
            {
              "name": "exportId",
              "type": {
                "type": "string",
                "avro.java.string": "String"
              }
            },
            {
              "name": "exportType",
              "type": {
                "type": "string",
                "avro.java.string": "String"
              }
            },
            {
              "name": "exportQuery",
              "type": {
                "type": "record",
                "name": "ExportQuery",
                "fields": [
                  {
                    "name": "postExport",
                    "type": [
                      "null",
                      {
                        "type": "record",
                        "name": "PostExport",
                        "fields": [
                          {
                            "name": "postId",
                            "type": {
                              "type": "string",
                              "avro.java.string": "String"
                            }
                          },
                          {
                            "name": "isCommentIncluded",
                            "type": "boolean"
                          }
                        ]
                      }
                    ],
                    "default": null
                  },
                  {
                    "name": "feedExport",
                    "type": [
                      "null",
                      {
                        "type": "record",
                        "name": "FeedExport",
                        "fields": [
                          {
                            "name": "accounts",
                            "type": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "avro.java.string": "String"
                              }
                            }
                          },
                          {
                            "name": "recordTypes",
                            "type": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "avro.java.string": "String"
                              }
                            }
                          },
                          {
                            "name": "actions",
                            "type": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "avro.java.string": "String"
                              }
                            }
                          },
                          {
                            "name": "contentTypes",
                            "type": {
                              "type": "array",
                              "items": {
                                "type": "string",
                                "avro.java.string": "String"
                              }
                            }
                          },
                          {
                            "name": "startDate",
                            "type": "long"
                          },
                          {
                            "name": "endDate",
                            "type": "long"
                          },
                          {
                            "name": "advancedSearch",
                            "type": [
                              "null",
                              {
                                "type": "record",
                                "name": "AdvancedSearchExport",
                                "fields": [
                                  {
                                    "name": "allOfTheWords",
                                    "type": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "avro.java.string": "String"
                                      }
                                    }
                                  },
                                  {
                                    "name": "anyOfTheWords",
                                    "type": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "avro.java.string": "String"
                                      }
                                    }
                                  },
                                  {
                                    "name": "noneOfTheWords",
                                    "type": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "avro.java.string": "String"
                                      }
                                    }
                                  },
                                  {
                                    "name": "hashtags",
                                    "type": {
                                      "type": "array",
                                      "items": {
                                        "type": "string",
                                        "avro.java.string": "String"
                                      }
                                    }
                                  },
                                  {
                                    "name": "keyword",
                                    "type": {
                                      "type": "string",
                                      "avro.java.string": "String"
                                    }
                                  },
                                  {
                                    "name": "exactPhrase",
                                    "type": {
                                      "type": "string",
                                      "avro.java.string": "String"
                                    }
                                  }
                                ]
                              }
                            ],
                            "default": null
                          }
                        ]
                      }
                    ],
                    "default": null
                  }
                ]
              }
            }
          ]
        }
      }
    ]
  }
  </code></pre>
  
  <p>Json message:</p>
  
  <pre><code>   {
          "context": {
              "user_id": "1",
              "group_id": "1",
              "organization_id": "1"
          },
          "exportInfo": {
              "exportId": "93874dd7-35d7-4f1f-8cf8-051c606d920b",
              "exportType": "json",
              "exportQuery": {
                  "postExport": {
                      "postId": "dd",
                      "isCommentIncluded": false
                  },
                  "feedExport": {
                      "accounts": [
                          "1677143852565319"
                      ],
                      "recordTypes": [],
                      "actions": [],
                      "contentTypes": [],
                      "startDate": 0,
                      "endDate": 0,
                      "advancedSearch": {
                          "allOfTheWords": [
                              "string"
                          ],
                          "anyOfTheWords": [
                              "string"
                          ],
                          "noneOfTheWords": [
                              "string"
                          ],
                          "hashtags": [
                              "string"
                          ],
                          "keyword": "string",
                          "exactPhrase": "string"
                      }
                  }
              }
          }
      }
  </code></pre>
  
  <p>I would appreciate it if someone could help me to understand what the issue is.</p>