Skip to content

Fix union full name typing#154

Closed
zatlodan wants to merge 1 commit intoovotech:mainfrom
zatlodan:main
Closed

Fix union full name typing#154
zatlodan wants to merge 1 commit intoovotech:mainfrom
zatlodan:main

Conversation

@zatlodan
Copy link

@zatlodan zatlodan commented Feb 3, 2024

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.

@zatlodan zatlodan requested a review from a team as a code owner February 3, 2024 05:01
@jit-ci
Copy link

jit-ci bot commented Feb 3, 2024

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.

@formatlos
Copy link

Also came across this issue, I'd also need this to be merged soon. @zatlodan thanks for fixing

@tlindener
Copy link

Would be great if someone could take a look at this! :)

@aug24
Copy link

aug24 commented Feb 5, 2025

Closed because very stale.

@aug24 aug24 closed this Feb 5, 2025
@aug24 aug24 reopened this Feb 5, 2025
@aug24
Copy link

aug24 commented Feb 5, 2025

Apologies for overzealous closing. We are tidying up stale tickets assigned to our team

@aug24
Copy link

aug24 commented Feb 5, 2025

Closed because very stale.

@aug24 aug24 closed this Feb 5, 2025
@zatlodan
Copy link
Author

zatlodan commented Feb 5, 2025

@aug24 This is still not fixed, we are still waiting for this to get merged and released.

Reopening this here: #161

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants