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

Generator should skip generation for empty services #2750

Closed
alicejli opened this issue May 7, 2024 · 4 comments · Fixed by #3051
Closed

Generator should skip generation for empty services #2750

alicejli opened this issue May 7, 2024 · 4 comments · Fixed by #3051
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@alicejli
Copy link
Contributor

alicejli commented May 7, 2024

A scenario came up with googleapis/google-cloud-java#10802 where https://github.com/googleapis/googleapis/blob/master/google/cloud/visionai/v1/prediction.proto contains an empty service (e.g. no RPCs).

There tests fail when trying to compile the generated library containing this proto which means the generator is generating some classes for this empty service which are not compilable. The generator instead should skip generation for an empty service.

@alicejli alicejli added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels May 7, 2024
@blakeli0
Copy link
Collaborator

Similar issue #2050 where the gapic generator errors out if no service exists.

@blakeli0
Copy link
Collaborator

blakeli0 commented May 28, 2024

Possible solutions:

  1. Skip generation clients if no RPCs found for a service.
  2. Generate an empty client, no ideal but maybe there is a use case for empty clients.

@zhumin8
Copy link
Contributor

zhumin8 commented Jul 16, 2024

Possible solutions:

  1. Skip generation clients if no RPCs found for a service.
  2. Generate an empty client, no ideal but maybe there is a use case for empty clients.

Currently I am opting for option 1 in #3051, to skip generation altogether if no RPCs found in a service (filter in parsing services). However, I run into a conflict with this test, and discovered this relative old pr that put on a check for empty services for sample composers.

  • The above pr only fixes for sample code composers, thus we are still observing this behavior as reported in this issue.
  • The behavior in above pr still generates samples for empty services, while discussion on the pr seams to suggest it was a quick fix to not error out and author and reviewers seems to have consensus that services without RPCs should not be a thing.
  • this was originally a fix to enable sqladmin API, but I don’t see sql admin generated in google-cloud-java. Any context?

I want to run this quickly by @blakeli0 to check if you think it's okay to not generate clients for empty services that do not have RPCs? Or otherwise, is empty services like this one a legit use case?

@blakeli0
Copy link
Collaborator

Thanks for the investigation @zhumin8 ! I don't think this is a legit use case, the PR was probably trying to resolve a presubmit check internally when this proto was introduced.
Since the specific service never request generation for a Java library, means there would be no breaking change once this issue is fixed, I think we are safe to not generating clients for empty services.

zhumin8 added a commit that referenced this issue Jul 23, 2024
fixes #2750
Skip parsing a service if no RPCs found for. 
In the scenario that only one service with no RPCs or all services have
no RPCs, falls back to #2460

This pr also reverts a change brought by #985, and removes the relevant
tests. For more context, this has been discussed
[here](#2750 (comment)).

---------

Co-authored-by: Lawrence Qiu <lawrenceqiu@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants