8000 TypeError: MessageToJson() got an unexpected keyword argument 'including_default_value_fields' · Issue #431 · googleapis/proto-plus-python · GitHub
[go: up one dir, main page]

Skip to content
TypeError: MessageToJson() got an unexpected keyword argument 'including_default_value_fields' #431
Closed
@parthea

Description

@parthea

The following stack trace below appears when testing protobuf==5.26.0rc2 : https://pypi.org/project/protobuf/5.26.0rc2/

The error is occurring because the including_default_value_fields argument was renamed in MessageToJson and MessageToDict.

Related commit in upstream protobuf repository: protocolbuffers/protobuf@2699579

    def to_json(
        cls,
        instance,
        *,
        use_integers_for_enums=True,
        including_default_value_fields=True,
        preserving_proto_field_name=False,
        sort_keys=False,
        indent=2,
        float_precision=None,
    ) -> str:
        """Given a message instance, serialize it to json
    
        Args:
            instance: An instance of this message type, or something
                compatible (accepted by the type's constructor).
            use_integers_for_enums (Optional(bool)): An option that determines whether enum
                values should be represented by strings (False) or integers (True).
                Default is True.
            preserving_proto_field_name (Optional(bool)): An option that
                determines whether field name representations preserve
                proto case (snake_case) or use lowerCamelCase. Default is False.
            sort_keys (Optional(bool)): If True, then the output will be sorted by field names.
                Default is False.
            indent (Optional(int)): The JSON object will be pretty-printed with this indent level.
                An indent level of 0 or negative will only insert newlines.
                Pass None for the most compact representation without newlines.
            float_precision (Optional(int)): If set, use this to specify float field valid digits.
                Default is None.
        Returns:
            str: The json string representation of the protocol buffer.
        """
>       return MessageToJson(
            cls.pb(instance),
            use_integers_for_enums=use_integers_for_enums,
            including_default_value_fields=including_default_value_fields,
            preserving_proto_field_name=preserving_proto_field_name,
            sort_keys=sort_keys,
            indent=indent,
            float_precision=float_precision,
        )
E       TypeError: MessageToJson() got an unexpected keyword argument 'including_default_value_fields'

Metadata

Metadata

Assignees

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.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0