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

Print count of unrecognized bytes in "buf curl" #2586

Merged
merged 1 commit into from
Nov 14, 2023
Merged

Conversation

jhump
Copy link
Member

@jhump jhump commented Nov 14, 2023

Currently, buf curl transcodes the response from the binary format to JSON. However, if the response includes any unrecognized fields, they are just discarded since JSON does not emit unrecognized field data.

So this provides a cue to user's that such data might be in the response and getting dropped (which suggests an incomplete or out-of-date schema) by logging the presence of unrecognized bytes when the -v flag is used.

While in here, I noticed that this was allowing unrecognized fields in the JSON request provided to buf curl, which seems wrong since a likely issue with formulating a request will be a typo in a field name, which would just be ignored instead of validated. I was tempted to fix this by simply using protojson directly. I don't really understand the value of protoencoding having to reproduce the same functionality with a different API. But I suspected you would object to that, so I instead addressed a TODO in here.

But it does beg the question in mind: why have these protoencoding wrappers? Why not directly use proto and protojson for serialization?

…t of unrecognized bytes in responses with -v
@jhump jhump requested a review from bufdev November 14, 2023 13:21
Copy link
Member

@bufdev bufdev left a comment

Choose a reason for hiding this comment

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

These wrappers give us a common way to do (and enforce) additional behavior on top of the main libs, such as json.compact (to get around the non-determinism problem), and if I remember, reparsing for custom options

@jhump
Copy link
Member Author

jhump commented Nov 14, 2023

@bufdev, ack. I forgot about protojson's non-deterministic output 😭.

@jhump jhump merged commit 9aaf28d into main Nov 14, 2023
9 checks passed
@jhump jhump deleted the jh/buf-curl-improvements branch November 14, 2023 14:22
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.

2 participants