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

fix: construct messages with nested struct #479

Merged
merged 8 commits into from
Jul 30, 2024

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
proto/marshal/rules/message.py Outdated Show resolved Hide resolved
proto/marshal/rules/message.py Show resolved Hide resolved
@ohmayr ohmayr merged commit aa4aa61 into main Jul 30, 2024
29 checks passed
@ohmayr ohmayr deleted the fix-for-messages-with-nested-struct branch July 30, 2024 17:34
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