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

Fix panic in buf curl that can happen with some map fields #2711

Merged
merged 2 commits into from
Jan 17, 2024

Conversation

jhump
Copy link
Member

@jhump jhump commented Jan 17, 2024

When -v is used, the command shows the amount of unrecognized data in the response. When it counts that data, a bug in one of the case expressions allowed it to fall into the wrong case (for a map whose values are not messages). This would then result in a panic:

panic: type mismatch: cannot convert map to message

The panic actually happens whether or not the user includes a -v option, since this part of the code calculates and prints the value unconditionally. (If -v is not specified, the "print" step is effectively a no-op.)

This branch fixes that panic and adds a test. The test uses a message with fields of every possible type (including groups) to make sure that all types are correctly handled without panic. The test reproduces the panic issue, and confirms the fix.

@mattrobenolt
Copy link
Contributor

🙏

@jhump jhump requested a review from bufdev January 17, 2024 20:25
@jhump jhump merged commit 7774390 into main Jan 17, 2024
9 checks passed
@jhump jhump deleted the jh/fix-panic-in-buf-curl branch January 17, 2024 20:51
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