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 MetadataKey::from_bytes #1246

Merged
merged 3 commits into from Feb 8, 2023

Conversation

andrewhickman
Copy link
Contributor

@andrewhickman andrewhickman commented Jan 20, 2023

Motivation

I tried using BinaryMetadataKey::from_bytes to parse a header value, but noticed it inconveniently panics on values that don't end in -bin.

Solution

I assume this is a bug since the signature of this function suggests it returns an error on failure, and the documentation makes no mention of panicking.

This PR fixes it to return an error instead.

The signature of this function suggests it returns an error on failure,
and the documentation makes no mention of panicking.
Copy link
Member

@LucioFranco LucioFranco left a comment

Choose a reason for hiding this comment

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

Nice catch! Thanks

tonic/src/metadata/key.rs Outdated Show resolved Hide resolved
@LucioFranco LucioFranco merged commit 930c805 into hyperium:master Feb 8, 2023
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.

None yet

2 participants