Skip to content

Bug: boolean with true as default are always true#44

Merged
cpiemontese merged 3 commits intomasterfrom
bug/default-true-booleans-always-are-true
Mar 19, 2026
Merged

Bug: boolean with true as default are always true#44
cpiemontese merged 3 commits intomasterfrom
bug/default-true-booleans-always-are-true

Conversation

@pau-sala
Copy link
Copy Markdown
Contributor

@pau-sala pau-sala commented Mar 19, 2026

Ciao!
When writing an integration test using the avrogen generated code I've found that a schema with a boolean field with a default set to true will always be true no matter the value, due to this line lib/avrogen/avro/types/record/field.ex:84

 # false || true is always true
quote(do: unquote(variable_name) = avro_map[unquote(name)] || unquote(default))

I've added a test, which fails with the code as is, and a possible fix.
TX!

@pau-sala pau-sala changed the title Bug: boolean with true as default always are true Bug: boolean with true as default are always true Mar 19, 2026
@pau-sala pau-sala marked this pull request as ready for review March 19, 2026 08:21
@pau-sala pau-sala requested a review from a team as a code owner March 19, 2026 08:21
cpiemontese
cpiemontese previously approved these changes Mar 19, 2026
Copy link
Copy Markdown
Contributor

@cpiemontese cpiemontese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow that's a subtle bug, thanks!

If you can update the CHANGELOG and run a suite-py bump, I will release the patch as soon as this is merged

@cpiemontese cpiemontese enabled auto-merge (squash) March 19, 2026 09:42
@cpiemontese cpiemontese merged commit 8b70e84 into master Mar 19, 2026
11 checks passed
@cpiemontese cpiemontese deleted the bug/default-true-booleans-always-are-true branch March 19, 2026 09:45
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.

2 participants