Skip to content

Option on buf convert to set DiscardUnknown to false when unmarshalling input #2714

Open
@lewchuk-span

Description

@lewchuk-span

I'd like to put a feature request for this todo to be implemented and exposed as a command line parameter. Specifically, as a parameter on buf convert.

My use case is that I am using buf convert to validate textpb files against my protobuf definitions. We have found that having samples of valid instances of protos along with the schema definitions helps our team understand the semantic intention of the schemas. To support this process we have implemented validation of those samples using buf convert which helps capture:

  • Basic invalid formats
  • Type errors on fields

In addition we want to reject samples which have extra fields on them. In our use case those extra fields are almost always caused by spelling mistakes on a field that does exist in the schema. In addition if the field with the spelling error is a message type all child fields get no validation at all potentially allowing type errors to slip through.

We have implemented a hacky solution using convert to output textpb and then using diff but this is a brittle solution (subject to the detrand randomness and requiring our samples to match the formatting of the proto textpb marshaller which might change with future versions). If we had a --error-on-unknown flag we could simplify our system making it more reliable and flexible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions