You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem is, that if we swap string and null types in the array, the the schema becomes invalid, because we need to use default value, and according to the avro specification default value type must match the first type in the union.
default: A default value for this field, used when reading instances that lack this field (optional). Permitted values depend on the field's schema type, according to the table below. Default values for union fields correspond to the first schema in the union Default values for bytes and fixed fields are JSON strings, where Unicode code points 0-255 are mapped to unsigned 8-bit byte values 0-255.
Expected behaviour
The error should not be raised
The text was updated successfully, but these errors were encountered:
Currently the gem is opinionated about this. If null is a member type within a union then usually people want it as the default, so I think this helps to catch a common error case. (The official avro ruby gem does not currently validate field defaults.)
While I think this should remain the default behavior of this gem, perhaps it could be made configurable to allow null anywhere within a union. Would you like to try opening a pull request to make this change?
@tjwp Despite the opnioned behaviour, I have to admit that this helped us to discover a miscommunication problem in our team:)
Would you like to try opening a pull request to make this change?
Unfortunately I don't have much capacities.. But if you can guide me where to start I can give it a try.
Otherwise please feel free to close the ticket.
Hi. thanks for the nice gem!
I'd like to report an issue.
Description
We have the following Avro schema:
That results into the following error on attempt to build model from it:
This exception comes from here: https://github.com/salsify/avromatic/blob/master/lib/avromatic/model/attributes.rb#L180
The problem is, that if we swap
string
andnull
types in the array, the the schema becomes invalid, because we need to usedefault
value, and according to the avro specification default value type must match the first type in the union.https://avro.apache.org/docs/1.8.2/spec.html#schema_record
Expected behaviour
The error should not be raised
The text was updated successfully, but these errors were encountered: