Skip to content

Conversation

@jknovi
Copy link

@jknovi jknovi commented Sep 27, 2025

When detecting if a oneof type will clash with other types we only compare against nested types, and for those only the snake_case version is validated against the oneof name. This allow room for conflicts when:

  • The collision would happen with an enum type.
  • The oneof name is a reserved word that when snaked gets sanitized as r#.

In this change the check for collisions is updated to consider enum types and compered against their capitalized camel case version which is the one that will be used on the type names causing the collision which makes builds using these protos to fail.

Added testcases that would repro these issues on the absence of this fix. Note that the test cases are legal protos that would be codegened without issues on other languanges.

@jknovi jknovi force-pushed the oneof-conflict branch 2 times, most recently from 24b47b7 to 22461eb Compare September 27, 2025 07:13
When detecting if a oneof type will clash with other types we only
compare against nested types, and for those only the snake_case version
is validated against the oneof name. This allow room for conflicts when:
 - The collision would happen with an enum type.
 - The oneof name is a reserved word that when snaked gets sanitized as
   r#<word>.

In this change the check for collisions is updated to consider enum
types and compered against their capitalized camel case version which
Copy link
Contributor

@caspermeijn caspermeijn left a comment

Choose a reason for hiding this comment

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

Thank you for spotting this problem.
Thank you for creating this PR.
Thank you for adding a good test case!

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