-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Description
Describe the bug
- I accept a NodeID (as String input in a text field) in a dialog in my app, to then connect to another node via iroh.
- I create a NodeId from the string, checking for Ok/Err.
- I have tests that check this works, and that invalid NodeIds are caught and the user informed
- When updating from iroh-net to iroh, this test fails with a panic.
Relevant Logs
Expected behavior
- NodeId::from_str() returns an error when an invalid string is passed in
Platform(s)
Desktop:
- OS: macos
- Version 15.3
Additional Context / Screenshots / GIFs
This code
impl FromStr for PublicKey {
type Err = KeyParsingError;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let bytes = decode_base32_hex(s)?;
Ok(Self::from_bytes(&bytes)?)
}
}
panics when you pass it a non-bas32 string (e.g. "invalid_node_id") and the parse error is not caught.
assert_eq!(Ok(output.len()), self.decode_len(input.len()));
in lib.rs:1453
I think that needs to be changed to return an Error, not panic.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Type
Projects
Status
✅ Done