ParseChar error always suggests urn:uuid: is a valid prefix #862

Closed
opened 2026-03-03 14:45:44 -06:00 by ginnyTheCat · 1 comment
ginnyTheCat commented 2026-03-03 14:45:44 -06:00 (Migrated from github.com)

When parsing an invalid UUID using Hyphenated

use std::str::FromStr;

use uuid::fmt::Hyphenated;

fn main() {
    println!("{}", Hyphenated::from_str("abcdefg").unwrap_err());
}

the following error is logged:

invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `g` at 7

In this case urn:uuid: is, however, not allowed, since it's being parsed using Hyphenated not a Uuid. This is quite confusing since it suggests to API consumers that this is a supported format, even though it's explicitly disallowed.

When parsing an invalid UUID using `Hyphenated` ```rust use std::str::FromStr; use uuid::fmt::Hyphenated; fn main() { println!("{}", Hyphenated::from_str("abcdefg").unwrap_err()); } ``` the following error is logged: ``` invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `g` at 7 ``` In this case `urn:uuid:` is, however, not allowed, since it's being parsed using `Hyphenated` not a `Uuid`. This is quite confusing since it suggests to API consumers that this is a supported format, even though it's explicitly disallowed.
KodrAus commented 2026-03-03 16:21:51 -06:00 (Migrated from github.com)

Thanks @ginnyTheCat. We should definitely improve that error message 👍

Thanks @ginnyTheCat. We should definitely improve that error message :+1:
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#862
No description provided.