Skip to content

chore: demo of showcase with json_name#12980

Draft
diegomarquezp wants to merge 1 commit intomainfrom
test/showcase-json-name
Draft

chore: demo of showcase with json_name#12980
diegomarquezp wants to merge 1 commit intomainfrom
test/showcase-json-name

Conversation

@diegomarquezp
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces new RPC methods (RepeatDataCustomPath, RepeatDataBodyCustomMessage, and RepeatDataCustomQuery) to the Compliance service, including the necessary proto definitions, client stubs, and tests. The review identified two high-severity issues in HttpJsonComplianceStub.java where json_name values were incorrectly used instead of proto field names for path parameters and request body mapping, which violates standard HTTP transcoding rules.

Comment on lines +531 to +539
"/v1beta1/repeat/{info.custom-path-field}:custompath",
request -> {
Map<String, String> fields = new HashMap<>();
ProtoRestSerializer<CustomBindingRequest> serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields,
"info.custom-path-field",
request.getInfo().getCustomPathField());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The path template and the parameter key in putPathParam use the json_name ("custom-path-field") instead of the proto field name ("custom_path_field"). According to AIP-127 and standard HTTP transcoding rules, path templates refer to proto field names. Using the json_name here is inconsistent with the proto definition (line 132 of compliance.proto) and also inconsistent with the routing header extraction logic later in this file (line 987), which correctly uses underscores.

Suggested change
"/v1beta1/repeat/{info.custom-path-field}:custompath",
request -> {
Map<String, String> fields = new HashMap<>();
ProtoRestSerializer<CustomBindingRequest> serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields,
"info.custom-path-field",
request.getInfo().getCustomPathField());
"/v1beta1/repeat/{info.custom_path_field}:custompath",
request -> {
Map<String, String> fields = new HashMap<>();
ProtoRestSerializer<CustomBindingRequest> serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields,
"info.custom_path_field",
request.getInfo().getCustomPathField());

request ->
ProtoRestSerializer.create()
.toBody(
"custom-body-message", request.getCustomBodyMessage(), false))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

high

The body parameter name in toBody should match the field name specified in the body option of the google.api.http annotation in the proto. The proto definition (line 140 of compliance.proto) uses the field name "custom_body_message", not the json_name "custom-body-message".

Suggested change
"custom-body-message", request.getCustomBodyMessage(), false))
"custom_body_message", request.getCustomBodyMessage(), false))

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.

1 participant