Skip to content

encoding/protojson: DiscardUnknown doesn't work for unknown enum strings #1208

Closed
@jjhuff

Description

@jjhuff

What version of protobuf and what language are you using?
Version: 1.24.0 (golang)

What did you do?
We're using protojson to encode our internal protobufs for indexing in ElasticSearch. For interop with other users, we encode enums as strings. At some point, we added a new enum value, which has caused older golang consumers to fail with the following error:
invalid value for enum type: "CLASS_RESULTS_PRE_CLINICAL"

What did you expect to see?
We set DiscardUnknown in UnmarshalOptions, so I would have expected the value to be parsed as the default enum value.

What did you see instead?
invalid value for enum type: "CLASS_RESULTS_PRE_CLINICAL"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions