fix(generator): fall back to java.lang.Object for unknown types.#31517
Open
diegomarquezp wants to merge 1 commit intomainfrom
Open
fix(generator): fall back to java.lang.Object for unknown types.#31517diegomarquezp wants to merge 1 commit intomainfrom
diegomarquezp wants to merge 1 commit intomainfrom
Conversation
Contributor
Author
|
fix demo for |
Contributor
|
There seem to be removed methods, is that expected? |
blakeli0
reviewed
Apr 16, 2026
| # return result | ||
| # | ||
| # raise ValueError('Unknown type: %s format: %s' % (json_type, json_format)) | ||
| # Fallback to the unformatted base type if exact format mapping is not found. |
Contributor
There was a problem hiding this comment.
I see that the generated code changed from
private java.util.Map<String, Any> entries;
to
private java.util.Map<String, java.lang.Object> entries;
Is it possible to test it in a real client?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #31266
Background
When compiling specific alpha/beta generated model endpoints (e.g.,
StructuredEntriesingoogle-api-services-compute), the Java compiler crashes on:This happens because the property
"entries"uses a schema format that the current Java generator does not explicitly handle, defined in the upstream discovery document here:discoveries/compute.alpha.json
Since
('any', 'google.protobuf.Value')has no dedicated mapping, the code generation fell through to the default class transformation logic.Faulty snippet in
java_generator.py:This resulted in the pseudo-class reference
Any.Changes Proposed
JavaLanguageModel._GetTypeInfoso that any unmapped(type, format)signature automatically strips the format requirement and probes the base(type, None)type list instead.google.protobuf.Value) to standard mappings (likejava.lang.Object), avoiding unintended transitive dependencies on externalprotobuf-javalibraries.Testing & Impact Verification
v1/2.0.0libraries to check for unintended regressions.