GeezerVison is showing github.com — Transcoding fails when HTTP request body contains a field name which is a reserved word in python · Issue #15074 · googleapis/google-cloud-python
Transcoding fails when HTTP request body contains a field name which is a reserved word in python #15074
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Description
There is an error in googleapis/python-debugger-client#151 which occurs in the transcoding logic when the name of the request field whose value is mapped to the HTTP request body is a reserved word in python. In the case of python-debugger-client, the breakpoint field is used in the HTTP request body here.
See the transcode function below.
https://github.com/googleapis/python-api-core/blob/2a6a36bd820e1344c8b2526eb75d0b9f3a055d3b/google/api_core/path_template.py#L250-L252
Gapic generator python adds a trailing underscore to field names if the name is also a reserved word in Python. A similar issue was reported in googleapis/python-api-core#227 and fixed in googleapis/python-api-core#228. Based on comment googleapis/python-api-core#227 (comment) it is not possible for fields to have a trailing _ at the proto level (Creating a field like this generates an error from the protobuf runtime).
See build log https://github.com/googleapis/python-debugger-client/actions/runs/4292539515/jobs/7479094983 which shows the failure when a request has body with breakpoint_ instead of breakpoint.
> response = client.set_breakpoint(request)
tests/unit/gapic/debugger_v2/test_debugger2.py:1920:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
google/cloud/debugger_v2/services/debugger2/client.py:547: in set_breakpoint
response = rpc(
.nox/unit-3-8/lib/python3.8/site-packages/google/api_core/gapic_v1/method.py:113: in __call__
return wrapped_func(*args, **kwargs)
.nox/unit-3-8/lib/python3.8/site-packages/google/api_core/timeout.py:120: in func_with_timeout
return func(*args, **kwargs)
.nox/unit-3-8/lib/python3.8/site-packages/google/api_core/grpc_helpers.py:72: in error_remapped_callable
return callable_(*args, **kwargs)
google/cloud/debugger_v2/services/debugger2/transports/rest.py:722: in __call__
transcoded_request = path_template.transcode(http_options, pb_request)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
http_options = [{'body': 'breakpoint', 'method': 'post', 'uri': '/v2/debugger/debuggees/{debuggee_id}/breakpoints/set'}]
message = debuggee_id: "sample1"
breakpoint_ {
id: "id_value"
action: LOG
location {
path: "path_value"
line: 424
...alue"
type_: "type__value"
var_table_index {
value: 541
}
status {
}
}
}
}
Activity
changed the title
[-]Issue in transcoding when [/-] [+]Issue in transcoding when body has a reserved keyword[/+] on Mar 7, 2023changed the title
[-]Issue in transcoding when body has a reserved keyword[/-] [+]Issue in transcoding when body is a reserved word in python[/+] on Mar 8, 2023changed the title
[-]Issue in transcoding when body is a reserved word in python[/-] [+]Transcoding fails when HTTP request body contains a field name which is a reserved word in python[/+] on Mar 8, 2023added
type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release. on Mar 27, 2023added
priority: p2Moderately-important priority. Fix may not be included in next release. and removed
priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release. on Apr 18, 2023parthea commented on Apr 18, 2023
ContributorAuthor
More actions
Bumping to P2 as this is blocking REST Transport support for 1 client library in googleapis/python-debugger-client#151. The REST Transport support feature has not yet launched for the python-debugger-client client library yet.
parthea commented on Jan 12, 2026
ContributorAuthor
More actions
Transferring to google-cloud-python as the code for python-api-core will be migrated there in 1-3 weeks.
daniel-sanche commented on May 27, 2026
This issue is being closed as part of a bulk review (Filter #1). Please reopen if you believe this is still relevant and requires action.
Metadata
Metadata
priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns. Development
No branches or pull requestsIssue actions