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

[ENCHANCEMENT] HoloHash::from_raw_39 - handle bad length as error instead of panicking #3313

Open
8e8b2c opened this issue Feb 7, 2024 · 2 comments
Assignees
Labels
good first issue Good for newcomers permanent Exempt this item from being marked stale and closed.

Comments

@8e8b2c
Copy link

8e8b2c commented Feb 7, 2024

Issue
Calling e.g. AgentPubKey::from_raw_39(bytes) on something that isn't 39 bytes long causes an assertion failure. This seems surprising seeing as the function returns a HoloHashResult, which includes the variant Err(HoloHashError::BadSize). This forces the developer to check the length proactively in addition to handling the result.

Expected behaviour
The function returns an Err instead of panicking.

@ThetaSinner ThetaSinner self-assigned this Feb 8, 2024
@ThetaSinner
Copy link
Contributor

Yes, this is unhelpful code! It's something I've run into and I'm afraid is still a TODO. Some of these hash types will accept some lengths that are known to the system like 36 and 32 bytes I believe, but then you'll get errors later.

I'll put this on my list to look at :) Thanks for raising it!

@ThetaSinner ThetaSinner pinned this issue Feb 19, 2024
@ThetaSinner ThetaSinner added the good first issue Good for newcomers label Feb 19, 2024
Copy link
Contributor

This item has been open for 30 days with no activity.

@github-actions github-actions bot added the stale This issue may be outdated, but we can revive it if it ever becomes relevant again label Mar 21, 2024
@ThetaSinner ThetaSinner added permanent Exempt this item from being marked stale and closed. and removed stale This issue may be outdated, but we can revive it if it ever becomes relevant again labels Mar 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers permanent Exempt this item from being marked stale and closed.
Projects
None yet
Development

No branches or pull requests

2 participants