Skip to content

Conversation

ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Jul 23, 2024

This PR fixes the issue to construct a message from a dictionary when a message has a nested struct.

from google.protobuf import struct_pb2
import proto


class Foo(proto.Message):
    struct_field: struct_pb2.Struct = proto.Field(
        proto.MESSAGE,
        number=1,
        message=struct_pb2.Struct,
    )

class Bar(proto.Message):
    foo_field: Msg1 = proto.Field(
        proto.MESSAGE,
        number=1,
        message=Msg1,
    )

# The following works:
Foo({"struct_field": {"foo": "cheese"}})

# The following does not work (without the fix):
Bar({"foo_field": {"struct_field": {"foo": "cheese"}}})

Googlers see b/321905145

@ohmayr ohmayr requested a review from a team as a code owner July 23, 2024 18:02
@parthea parthea marked this pull request as draft July 23, 2024 18:31
@parthea
Copy link
Contributor

parthea commented Jul 23, 2024

LGTM but holding off on formal review until cover is fixed

@ohmayr ohmayr marked this pull request as ready for review July 26, 2024 17:26
@parthea parthea added the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 29, 2024
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Jul 29, 2024
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.

3 participants