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

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

Open
lewchuk-span opened this issue Jan 18, 2024 · 0 comments

Comments

@lewchuk-span
Copy link

lewchuk-span commented Jan 18, 2024

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.

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

No branches or pull requests

1 participant