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

feat(generator/rust): skip duplicate enum values #1538

Merged

Conversation

coryan
Copy link
Contributor

@coryan coryan commented Mar 19, 2025

After converting the enum value names to Rust style we may find some
duplicates. With this change the generator can skip the dups. In all
practical cases the dups are harmless, they differ in case but have the
name numeric value. We warn if this assumption fails.

part of the work for #829

After converting the enum value names to Rust style we may find some
duplicates. With this change the generator can skip the dups. In all
practical cases the dups are harmless, they differ in case but have the
name numeric value. We warn if this assumption fails.
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.19%. Comparing base (58727a4) to head (ff9ed35).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1538   +/-   ##
=======================================
  Coverage   95.19%   95.19%           
=======================================
  Files          39       39           
  Lines        1603     1603           
=======================================
  Hits         1526     1526           
  Misses         77       77           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coryan coryan marked this pull request as ready for review March 19, 2025 12:49
@coryan coryan requested review from dbolduc and codyoss March 19, 2025 12:49
ID: ".test.v1.TestEnum.partial",
Number: 2,
}
// This does not happen in practice, but we want to verify the code can
Copy link
Member

Choose a reason for hiding this comment

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

This gave me pause. Maybe the generator should panic so we can go yell at the service team?

If we do receive the value 3, I guess we will just treat it as an UNKNOWN_VALUE:3 (or whatever). Which should be fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This gave me pause. Maybe the generator should panic so we can go yell at the service team?

I thought about that, but then we would stuck: sidekick update fails for all services, not just the offending one. We would need to hack something.

If we do receive the value 3, I guess we will just treat it as an UNKNOWN_VALUE:3 (or whatever). Which should be fine.

Exactly. It is very unlikely to happen (https://google.aip.dev/126 says enum values must be SCREAMING_SNAKE_CASE, the deviations are service bugs). And if it does happen we still can handle the incoming enums.

@coryan coryan merged commit a9c0c0c into googleapis:main Mar 19, 2025
20 checks passed
@coryan coryan deleted the feat-generator-rust-skip-duplicate-enum-values branch March 19, 2025 14: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