Mattias Andersson created AVRO-2897: ---------------------------------------
Summary: Unable to create nullable fields in Avro JavaScript implementation Key: AVRO-2897 URL: https://issues.apache.org/jira/browse/AVRO-2897 Project: Apache Avro Issue Type: Bug Components: javascript Affects Versions: 1.10.0 Reporter: Mattias Andersson I apologize in advance if this is a misunderstanding of funcitonality on my part and I have only tested it on the latest published npm package ([https://www.npmjs.com/package/avro-js]) but if not this should be a rather serious bug. According to multiple sources ([https://avro.apache.org/docs/1.8.1/spec.htm|https://avro.apache.org/docs/1.8.1/spec.html]), nullable values should be specified as a unon with the type null, e.g. for string "['null', 'string']" However, given the following code (that from what I understand should be valid) {code:java} var type = avro.parse({ name: 'Pet', type: 'record', fields: [ { name: 'name', type: ['null', 'string'] } ] }); var pet = { name: "Fido" }; var buf = type.toBuffer(pet); var obj = type.fromBuffer(buf); console.log(obj); {code} I get the followin error {code:java} Error: invalid ["null","string"]: "Fido" {code} Curiously, if I instead set pet name as "null" instead of "Fido" everything runs fine and returns a correct output given the input. Though this is not very useful as the field still can not be changed to anything else beside null. {code:java} Pet { name: null } {code} -- This message was sent by Atlassian Jira (v8.3.4#803005)