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
Remove HashType::htUnknown
#3650
Conversation
This does a few enums; the rest will be gotten in subsequent commits.
Instead, `Hash` uses `std::optional<HashType>`. In the future, we may also make `Hash` itself require a known hash type, encoraging people to use `std::optional<Hash>` instead.
A valid hash type must be provided now. The hash itself can still be invalid, but that doesn't cause an `abort()`.
HashType::Unknown
-- contains #3453HashType::Unknown
-- contains #3453
Now that we have a separate flag function, also describe why it is optional.
It is blank for SRI hashes.
HashType::Unknown
-- contains #3453HashType::Unknown
-- contains #3453
Whew! got it working. |
Not a regular git revert as there have been many merges and things.
HashType::Unknown
-- contains #3453HashType::Unknown
Hash h(ht); | ||
warn("found empty hash, assuming '%s'", h.to_string(SRI, true)); | ||
if (!ht) | ||
throw BadHash("empty hash requires explicit hash type"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new validation, actually. I think we want it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's okay if hash type is unset - you just have to have sri in your string
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this is just in the empty string case, when the SRI or legacy prefix can't help.
How is std::optional better than HashType::Unknown? They seem like two ways to represent the same thing to me. |
@matthewbauer Well the |
Instead,
Hash
usesstd::optional<HashType>
. In the future, we mayalso make
Hash
itself require a known hash type, encouraging people touse
std::optional<Hash>
instead.#3453 makes most of the noise.