Fix union full name typing
The algorithm for generating Avro Union types did not match the Avro specification: https://avro.apache.org/docs/1.11.1/specification/#names
Issue: Union properties with additional "undefined" namespace in the property name.
export interface RootRecord {
unionField: {
"undefined.RecordANamespace.SomeRecordA": RecordANamespaceSomeRecordA;
"undefined.RecordBNamespace.SomeRecordB"?: never;
} | {
"undefined.RecordANamespace.SomeRecordA"?: never;
"undefined.RecordBNamespace.SomeRecordB": RecordBNamespaceSomeRecordB;
};
}
When did this occur
- When there was no namespace provided anywhere
- When the union records/enums used a full name (including dots)
Example:
{
"type": "record",
"name": "RootRecord",
"fields": [
{
"name": "unionField",
"type": [
{
"type": "record",
"name": "RecordANamespace.SomeRecordA",
"fields": [
{
"name": "someRecordAField",
"type": "string"
}
]
},
{
"type": "record",
"name": "RecordBNamespace.SomeRecordB",
"fields": [
{
"name": "someRecordBField",
"type": "string"
}
]
}
]
}
]
}
Tests
I have added tests that use the avsc library encoding/decoding to confirm that the fix actually matches the avsc implementation.
Hi, I’m Jit, a friendly security platform designed to help developers build secure applications from day zero with an MVS (Minimal viable security) mindset.
In case there are security findings, they will be communicated to you as a comment inside the PR.
Hope you’ll enjoy using Jit.
Questions? Comments? Want to learn more? Get in touch with us.
Also came across this issue, I'd also need this to be merged soon. @zatlodan thanks for fixing