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

fix: add default library settings for incorrect lib version #2212

Merged
merged 5 commits into from
Oct 10, 2024

Conversation

ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Oct 9, 2024

consider the case where self.naming.proto_package differs from library_settings.version. Ideally, this shouldn't happen but if the version configured against library_settings.version is incorrect, it breaks our generator.

As an example, see: https://github.com/googleapis/googleapis/blob/master/google/cloud/confidentialcomputing/v1alpha1/confidentialcomputing_v1alpha1.yaml#L63 where the service yaml file for confidentialcomputing specifies an incorrect version for library settings.
In this case:

  • self.naming.proto_package = google.cloud.confidentialcomputing.v1alpha1
  • library_settings.version = google.cloud.confidentialcomputing.v1

@ohmayr ohmayr requested a review from a team as a code owner October 9, 2024 21:56
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Oct 9, 2024
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Oct 10, 2024
Copy link
Contributor

@parthea parthea left a comment

Choose a reason for hiding this comment

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

LGTM once a unit test is added that fails without the fix

Comment on lines +714 to 716
result[self.naming.proto_package] = client_pb2.ClientLibrarySettings(
version=self.naming.proto_package
)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
result[self.naming.proto_package] = client_pb2.ClientLibrarySettings(
version=self.naming.proto_package
)
result[self.naming.proto_package] = client_pb2.ClientLibrarySettings(
version=self.naming.proto_package
)

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 results in the style check to fail.

# - if library_settings.version != self.naming.proto_package (proto package name)
if self.naming.proto_package not in result:
result[self.naming.proto_package] = client_pb2.ClientLibrarySettings(
version=self.naming.proto_package
Copy link
Contributor

Choose a reason for hiding this comment

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

To confirm, you're not passing python_settings here like you are in line 704 because we intend to pass empty settings since they weren't explicitly specified for self.naming.proto_package version?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We want to set empty settings against self.naming.proto_package if the key is not already set in line 704 which happens only when someone has an incorrect library_settings.version configured in their service yaml. We're doing this so our generator doesn't if it fails to find the settings that it's looking for.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sg. You're confirming the intent I phrased, so I understood correctly. Thanks!

@ohmayr ohmayr merged commit de46272 into main Oct 10, 2024
75 checks passed
@ohmayr ohmayr deleted the fix-lib-settings branch October 10, 2024 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants