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

Messages with 'protobuf.Any' fields fail round trip dict construction #285

Open
software-dov opened this issue Jan 25, 2022 · 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

@software-dov
Copy link
Contributor

software-dov commented Jan 25, 2022

Consider the following snippet:

from google.protobuf import any_pb2
import proto

class Container(proto.Message):
    contents = proto.Field(any_pb2.Any, number=1)

class Thing(proto.Message):
    name = proto.Field(proto.STRING, number=1)

thing = Thing(name="Thing 1")
c = Container()
a = any_pb2.Any()
a.Pack(Thing.pb(thing))
c.contents = a

c_dict = Container.to_dict(c)
c_new = Container(mapping=c_dict)  # Raises an exception

This fails because the dict representation for any_pb2.Any contains metadata that proto.Message.__init__ and proto.Message.__setattr__ do not know how to handle/ignore properly.

This blocks the use of the REST transport for any API method with a request that contains an any_pb2.Any fields due to transcoding logic.

@software-dov software-dov added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 25, 2022
software-dov added a commit to software-dov/gapic-generator-python that referenced this issue Jan 25, 2022
* Use url_scheme when setting host name for REST transports

* Expect correct exceptions in showcase tests

* Fix the noxfile to fail if the precise interpreter required is missing

* Temporarily bypass failing showcase tests for REST
** See googleapis/proto-plus-python#285 for
details

* In the showcase test setup, set the event loop once
software-dov added a commit to software-dov/gapic-generator-python that referenced this issue Jan 25, 2022
* Use url_scheme when setting host name for REST transports

* Expect correct exceptions in showcase tests

* Fix the noxfile to fail if the precise interpreter required is missing

* Temporarily bypass failing showcase tests for REST
** See googleapis/proto-plus-python#285 for
details

* In the showcase test setup, set the event loop once
software-dov added a commit to software-dov/gapic-generator-python that referenced this issue Jan 27, 2022
* Use url_scheme when setting host name for REST transports

* Expect correct exceptions in showcase tests

* Fix the noxfile to fail if the precise interpreter required is missing

* Temporarily bypass failing showcase tests for REST
** See googleapis/proto-plus-python#285 for
details

* In the showcase test setup, set the event loop once
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels May 8, 2022
@vchudnov-g vchudnov-g self-assigned this Jun 23, 2022
@vchudnov-g
Copy link
Contributor

We are thinking about this issue, which affects multiple languages using protocol buffers over HTTP/JSON. We will continue providing updates, though the issue may not be completely resolved soon.

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

No branches or pull requests

3 participants