-
Notifications
You must be signed in to change notification settings - Fork 69
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: Adjust Field Names in URI Templates #1041
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, with one comment
@@ -452,6 +452,19 @@ def test_method_http_options_additional_bindings(): | |||
}] | |||
|
|||
|
|||
def test_method_http_options_reserved_name_in_url(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also add the short template format ({license}
) here too (and ideally some other reserverd name besides license).
In general, please treat the short format as a first-class citizen for all grpc transcodding work, because this is the only format used in compute, which is the most importantlibrary relying on rest format.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have that form in the unit test test_uri_conv.py. I can add other names.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the test there already includes reversed
as well as license
:
def test_convert_uri_fieldname():
uri = "abc/*/license/{license}/{xyz.reversed=reversed/*}"
expected_uri = "abc/*/license/{license_}/{xyz.reversed_=reversed/*}"
assert utils.convert_uri_fieldnames(uri) == expected_uri
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is license
a reserved keyword? I think this should be fixed.
Validated that these changes fix the compute problem. |
@busunkim96, @software-dov I pushed this PR to unblock compute work. Please review it and if you have any requested chagnes, I'm happy to push them with a subsequent PR. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me!
Please try to finalize this logic before any libraries using this goes GA. We've had instances in the past where changing reserved names resulted in breaking changes on GA libraries.
|
||
last = 0 | ||
pieces = [] | ||
for match in path_template._VARIABLE_RE.finditer(uri): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can _VARIABLE_RE
be made public in google-api-core
? Otherwise someone might assume it's only used in google-api-core
and make a change that breaks the generator.
Slightly lower priority since it's in the generator code and not in generated library code.
Message fields that conflict with python reserved names are modified with a trailing underscore. If such a field appears in a uri template in an http option on a method, it needs to get the corresponding adjustment.