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

protobuf: refactor proto visitor pattern. #10354

Merged
merged 1 commit into from
Mar 15, 2020

Conversation

htuch
Copy link
Member

@htuch htuch commented Mar 12, 2020

Move the proto traversal handling in version_converter.cc to a
standalone library. This lets us replace existing proto visitor patterns in
common/protobuf/utility.cc for unexpected field checks.

The redaction code is actually a bit more involved, so I'm not
refactoring this; it needs to recurse through Any/TypedStruct.
Ultimately we might want something like this, but it doesn't seem super
helpful given we only have a the single instance of this right now.

Risk level: Low
Testing: Existing tests continue to pass.

Signed-off-by: Harvey Tuch htuch@google.com

Move the proto traversal handling in version_converter.cc to a
standalone library. This lets us replace existing proto visitor patterns in
common/protobuf/utility.cc for unexpected field checks.

The redaction code is actually a bit more involved, so I'm not
refactoring this; it needs to recurse through Any/TypedStruct.
Ultimately we might want something like this, but it doesn't seem super
helpful given we only have a the single instance of this right now.

Risk level: Low
Testing: Existing tests continue to pass.

Signed-off-by: Harvey Tuch <htuch@google.com>
@htuch
Copy link
Member Author

htuch commented Mar 12, 2020

@alyssawilk this continues #9807; I didn't seem to be able to reopen that PR.

@alyssawilk alyssawilk self-assigned this Mar 13, 2020
}
// We use the validation visitor but have hard coded behavior below for deprecated fields.
// TODO(htuch): Unify the deprecated and unknown visitor handling behind the validation
// visitor pattern. https://github.com/envoyproxy/envoy/issues/8092.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking: you still have further cleanup plans?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. This PR just refactors some proto traversal stuff. #8092 tracks the more general "move the deprecated field error reporting and exception generation to the validation visitor callbacks", i.e. having an onDeprecatedField() callback alongside onUnknownField() in ValidationVisitor. This is mostly a mechanical code movement that shouldn't really change any existing behavior. @nezdolik FYI.

@mattklein123 mattklein123 merged commit 3bbdc68 into envoyproxy:master Mar 15, 2020
@htuch htuch deleted the refactor-proto-visitor branch March 16, 2020 17:58
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