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

cannot use "case" as a field name #956

Closed
alexander-fenster opened this issue Feb 25, 2022 · 5 comments
Closed

cannot use "case" as a field name #956

alexander-fenster opened this issue Feb 25, 2022 · 5 comments
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

@alexander-fenster
Copy link
Contributor

If a field is named case in the protos, the generator fails with the following exception:

Exception in thread "main" com.google.api.generator.engine.ast.IdentifierNode$InvalidIdentifierException: Name case cannot be a keyword.
	at com.google.api.generator.engine.ast.IdentifierNode$Builder.build(IdentifierNode.java:99)
	at com.google.api.generator.engine.ast.IdentifierNode$Builder.buildVariableIdentifier(IdentifierNode.java:63)
	at com.google.api.generator.engine.ast.Variable$Builder.build(Variable.java:46)
	at com.google.api.generator.gapic.composer.common.AbstractServiceClientClassComposer.lambda$createMethodVariants$6(AbstractServiceClientClassComposer.java:668)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195)
	at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1655)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578)
	at com.google.api.generator.gapic.composer.common.AbstractServiceClientClassComposer.createMethodVariants(AbstractServiceClientClassComposer.java:671)
	at com.google.api.generator.gapic.composer.common.AbstractServiceClientClassComposer.createServiceMethods(AbstractServiceClientClassComposer.java:578)
	at com.google.api.generator.gapic.composer.common.AbstractServiceClientClassComposer.createClassMethods(AbstractServiceClientClassComposer.java:216)
	at com.google.api.generator.gapic.composer.common.AbstractServiceClientClassComposer.generate(AbstractServiceClientClassComposer.java:150)
	at com.google.api.generator.gapic.composer.Composer.lambda$generateClientSettingsClasses$3(Composer.java:134)
	at com.google.common.collect.ImmutableList.forEach(ImmutableList.java:422)
	at com.google.api.generator.gapic.composer.Composer.generateClientSettingsClasses(Composer.java:122)
	at com.google.api.generator.gapic.composer.Composer.generateServiceClasses(Composer.java:58)
	at com.google.api.generator.gapic.composer.Composer.composeServiceClasses(Composer.java:45)
	at com.google.api.generator.gapic.Generator.generateGapic(Generator.java:30)
	at com.google.api.generator.Main.main(Main.java:28)
--java_gapic_out: protoc-gen-java_gapic: Plugin failed with status code 1.

AIP-140 suggests that the APIs should not use possible keywords in names but does not forbid it, and this specific API won't be able to rename it because it's already public.

@alexander-fenster alexander-fenster added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Feb 25, 2022
@suztomo
Copy link
Member

suztomo commented Feb 25, 2022

@suztomo
Copy link
Member

suztomo commented Feb 25, 2022

@alexander-fenster (Aside from deciding what to do with gapic-generator-java) Do you know who introduced the "case" field. Is it possible to provide the feedback to the person (and approvers) that you are suffering the "case" field conflicting with Java's keywords?

Do other gapic-generators work fine for the field?

@alexander-fenster
Copy link
Contributor Author

@suztomo I added a comment in the internal issue 221506923 because the offending proto is not yet public.

@yihanzhen
Copy link
Contributor

yihanzhen commented Mar 2, 2022

I had a similar issue when I tried to generate Java libraries for artifactregistry API where a resource name has the collection name "package" in it (proto link). The resource should have be annotated with google.api.resource but doing so would cause Java generation to fail.

Let me know if you want me to create a separate issue or paste you the full stacktrace.

@alicejli
Copy link
Contributor

alicejli commented May 31, 2022

@vam-google pushed a fix for a related issue here: #985 that solves this issue as well.

suztomo pushed a commit that referenced this issue Mar 21, 2023
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [protobuf](https://developers.google.com/protocol-buffers/) | `==3.19.5` -> `==3.20.2` | [![age](https://badges.renovateapi.com/packages/pypi/protobuf/3.20.2/age-slim)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://badges.renovateapi.com/packages/pypi/protobuf/3.20.2/adoption-slim)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://badges.renovateapi.com/packages/pypi/protobuf/3.20.2/compatibility-slim/3.19.5)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://badges.renovateapi.com/packages/pypi/protobuf/3.20.2/confidence-slim/3.19.5)](https://docs.renovatebot.com/merge-confidence/) |

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Renovate will not automatically rebase this PR, because other commits have been found.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, click this checkbox. ⚠ **Warning**: custom changes will be lost.

---

This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/googleapis/java-core).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzMi4yMDguMiIsInVwZGF0ZWRJblZlciI6IjMyLjIwOC4yIn0=-->
suztomo pushed a commit that referenced this issue Mar 21, 2023
🤖 I have created a release *beep* *boop*
---


## [2.8.17](googleapis/java-core@v2.8.16...v2.8.17) (2022-09-28)


### Dependencies

* Update dependency cachetools to v5 ([#943](googleapis/java-core#943)) ([1406c09](googleapis/java-core@1406c09))
* Update dependency certifi to v2022.9.24 ([#934](googleapis/java-core#934)) ([b6e1904](googleapis/java-core@b6e1904))
* Update dependency charset-normalizer to v2.1.1 ([#938](googleapis/java-core#938)) ([ac43d61](googleapis/java-core@ac43d61))
* Update dependency click to v8.1.3 ([#946](googleapis/java-core#946)) ([05fe31f](googleapis/java-core@05fe31f))
* Update dependency com.google.api.grpc:proto-google-common-protos to v2.9.4 ([#945](googleapis/java-core#945)) ([3ebff6f](googleapis/java-core@3ebff6f))
* Update dependency gcp-releasetool to v1.8.8 ([#935](googleapis/java-core#935)) ([0f99ae1](googleapis/java-core@0f99ae1))
* Update dependency google-api-core to v2.10.1 ([#947](googleapis/java-core#947)) ([dedddfe](googleapis/java-core@dedddfe))
* Update dependency google-auth to v2.12.0 ([#948](googleapis/java-core#948)) ([67e53aa](googleapis/java-core@67e53aa))
* Update dependency google-cloud-core to v2.3.2 ([#936](googleapis/java-core#936)) ([a0d2e3e](googleapis/java-core@a0d2e3e))
* Update dependency google-cloud-storage to v2.5.0 ([#949](googleapis/java-core#949)) ([6edc6e3](googleapis/java-core@6edc6e3))
* Update dependency google-crc32c to v1.5.0 ([#950](googleapis/java-core#950)) ([0dda0a2](googleapis/java-core@0dda0a2))
* Update dependency googleapis-common-protos to v1.56.4 ([#937](googleapis/java-core#937)) ([b22a2b1](googleapis/java-core@b22a2b1))
* Update dependency importlib-metadata to v4.12.0 ([#951](googleapis/java-core#951)) ([6abe579](googleapis/java-core@6abe579))
* Update dependency jeepney to v0.8.0 ([#952](googleapis/java-core#952)) ([6a392e8](googleapis/java-core@6a392e8))
* Update dependency jinja2 to v3.1.2 ([#953](googleapis/java-core#953)) ([18a54a7](googleapis/java-core@18a54a7))
* Update dependency keyring to v23.9.3 ([#954](googleapis/java-core#954)) ([5ceabaa](googleapis/java-core@5ceabaa))
* Update dependency markupsafe to v2.1.1 ([#955](googleapis/java-core#955)) ([f64e9bf](googleapis/java-core@f64e9bf))
* Update dependency protobuf to v3.20.2 ([#956](googleapis/java-core#956)) ([fb1aea6](googleapis/java-core@fb1aea6))
* Update dependency protobuf to v4 ([#944](googleapis/java-core#944)) ([6b02535](googleapis/java-core@6b02535))
* Update dependency pyjwt to v2.5.0 ([#939](googleapis/java-core#939)) ([cc8ba46](googleapis/java-core@cc8ba46))
* Update dependency requests to v2.28.1 ([#940](googleapis/java-core#940)) ([ec195e3](googleapis/java-core@ec195e3))
* Update dependency typing-extensions to v4.3.0 ([#941](googleapis/java-core#941)) ([4c414e9](googleapis/java-core@4c414e9))
* Update dependency zipp to v3.8.1 ([#942](googleapis/java-core#942)) ([6dfb0d8](googleapis/java-core@6dfb0d8))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
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

No branches or pull requests

4 participants