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

Transcoding fails when HTTP request body contains a field name which is a reserved word in python #490

Open
parthea opened this issue Mar 7, 2023 · 1 comment
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

@parthea
Copy link
Collaborator

parthea commented Mar 7, 2023

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.

def transcode(http_options, message=None, **request_kwargs):
"""Transcodes a grpc request pattern into a proper HTTP request following the rules outlined here,
https://github.com/googleapis/googleapis/blob/master/google/api/http.proto#L44-L312

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 #227 and fixed in #228. Based on comment #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 {
      }
    }
  }
}
@parthea parthea changed the title Issue in transcoding when Issue in transcoding when body has a reserved keyword Mar 7, 2023
@parthea parthea changed the title Issue in transcoding when body has a reserved keyword Issue in transcoding when body is a reserved word in python Mar 8, 2023
@parthea parthea changed 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 Mar 8, 2023
@parthea parthea self-assigned this Mar 24, 2023
@parthea parthea added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Mar 27, 2023
@parthea parthea assigned atulep and unassigned parthea Mar 29, 2023
@parthea parthea added priority: p2 Moderately-important priority. Fix may not be included in next release. and removed priority: p1 Important issue which blocks shipping the next release. Will be fixed prior to next release. labels Apr 18, 2023
@parthea
Copy link
Collaborator Author

parthea commented Apr 18, 2023

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.

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

Successfully merging a pull request may close this issue.

2 participants