Summary
When attempting to serialize an Avro union type ["null", "string"] using the Schema Registry client, an error is thrown during the NativeFromTextual conversion process. The error encountered is as follows
NativeFromTextual conversion failed: cannot decode textual record "com.example.audit.AuditEvent": cannot decode textual union: expected: '{'; actual: '"' for key: "name"
Steps to Reproduce
Define an Avro schema with a union type (["null", "string"]) for the name field:
Summary When attempting to serialize an Avro union type ["null", "string"] using the Schema Registry client, an error is thrown during the NativeFromTextual conversion process. The error encountered is as follows
NativeFromTextual conversion failed: cannot decode textual record "com.example.audit.AuditEvent": cannot decode textual union: expected: '{'; actual: '"' for key: "name"
Steps to Reproduce{ "fields": [ { "name": "uuid", "type": "string" }, { "default": null, "name": "name", "type": ["null", "string"] } ], "name": "AuditEvent", "namespace": "com.example.audit", "type": "record" }
type AuditTrailEventData struct { UUID string
json:"uuid"Name string
json:"name"}
`value, err := json.Marshal(dto) if err != nil { slogger.GetInstance().WithContext(ctx).Errorf("Failed to marshal dto: %s", err) return err }
` I would appreciate guidance or a fix for handling union types with Avro serialization in Go.