Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unions with different type order panic #166

Closed
rgalus opened this issue May 17, 2021 · 1 comment
Closed

unions with different type order panic #166

rgalus opened this issue May 17, 2021 · 1 comment

Comments

@rgalus
Copy link
Contributor

rgalus commented May 17, 2021

The issue happened when migrating from v7 to v8. Looks like when 2 fields has same union but with different order in the schema it returns an error.

Schema:

{
	"type": "record",
	"name": "record_v1",
	"fields": [
		{
			"name": "foo",
			"type": ["null", "string"]
		},
		{
			"name": "bar",
			"type": ["string", "null"]
		}
	]
}

Fixtures:

[
    {
        "foo": {
            "string": "foo_string"
        },
        "bar": {
            "string": "bar_string"
        }
    }
]

Returns an error:

Panic at pc 17 - Unable to assign string to null field (set(string))

Test that reproduce issue:

https://github.com/rgalus/gogen-avro/commit/b284c619deaa93ff8f63730d9c1bda3249b672f9

@actgardner
Copy link
Owner

Hey @rgalus, thanks for the very detailed and clear bug report! This was pretty simple to resolve but it involved changing the name of the type generated for unions containing null, so I've cut a new major release (v9) to reflect that breaking change. Let me know if you run into any more issues :)

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

No branches or pull requests

2 participants