Uuid::parse_str reports incorrect final group lengths for invalid wrapped UUIDs #881

Closed
opened 2026-04-26 07:01:28 -05:00 by trrk · 0 comments
trrk commented 2026-04-26 07:01:28 -05:00 (Migrated from github.com)

Uuid::parse_str seems to report incorrect final group lengths for invalid wrapped UUIDs.

Reproduction

  • uuid: 1.23.0
use uuid::Uuid;

fn main() {
    println!("{}", Uuid::parse_str("urn:uuid:550e8400-e29b-41d4-a716-446655440000abc").unwrap_err());
    println!("{}", Uuid::parse_str("urn:uuid:550e8400-e29b-41d4-a716-44665544").unwrap_err());
    println!("{}", Uuid::parse_str("urn:uuid:550e8400-e29b-41d4-a716-446").unwrap_err());
    println!("{}", Uuid::parse_str("{550e8400-e29b-41d4-a716-446655440000abc}").unwrap_err());
    println!("{}", Uuid::parse_str("{550e8400-e29b-41d4-a716-44665544}").unwrap_err());
    println!("{}", Uuid::parse_str("{550e8400-e29b-41d4-a716-4466554400}").unwrap_err());
}

Current output:

invalid group length in group 4: expected 12, found 24
invalid group length in group 4: expected 12, found 17
invalid group length in group 4: expected 12, found 12
invalid group length in group 4: expected 12, found 17
invalid group length in group 4: expected 12, found 10
invalid group length in group 4: expected 12, found 12

Expected behavior

The reported final group length should be the actual length of the final UUID group.

Expected output:

invalid group length in group 4: expected 12, found 15
invalid group length in group 4: expected 12, found 8
invalid group length in group 4: expected 12, found 3
invalid group length in group 4: expected 12, found 15
invalid group length in group 4: expected 12, found 8
invalid group length in group 4: expected 12, found 10

Suspected cause

The final group length seems to be incorrectly calculated.

For URN inputs, the reported value seems to include the 9-character urn:uuid: prefix.

15 + 9 = 24
8 + 9 = 17
3 + 9 = 12

For braced inputs, the reported value seems to include both braces.

15 + 2 = 17
8 + 2 = 10
10 + 2 = 12
`Uuid::parse_str` seems to report incorrect final group lengths for invalid wrapped UUIDs. ## Reproduction * uuid: 1.23.0 ```rust use uuid::Uuid; fn main() { println!("{}", Uuid::parse_str("urn:uuid:550e8400-e29b-41d4-a716-446655440000abc").unwrap_err()); println!("{}", Uuid::parse_str("urn:uuid:550e8400-e29b-41d4-a716-44665544").unwrap_err()); println!("{}", Uuid::parse_str("urn:uuid:550e8400-e29b-41d4-a716-446").unwrap_err()); println!("{}", Uuid::parse_str("{550e8400-e29b-41d4-a716-446655440000abc}").unwrap_err()); println!("{}", Uuid::parse_str("{550e8400-e29b-41d4-a716-44665544}").unwrap_err()); println!("{}", Uuid::parse_str("{550e8400-e29b-41d4-a716-4466554400}").unwrap_err()); } ``` Current output: ```text invalid group length in group 4: expected 12, found 24 invalid group length in group 4: expected 12, found 17 invalid group length in group 4: expected 12, found 12 invalid group length in group 4: expected 12, found 17 invalid group length in group 4: expected 12, found 10 invalid group length in group 4: expected 12, found 12 ``` ## Expected behavior The reported final group length should be the actual length of the final UUID group. Expected output: ```text invalid group length in group 4: expected 12, found 15 invalid group length in group 4: expected 12, found 8 invalid group length in group 4: expected 12, found 3 invalid group length in group 4: expected 12, found 15 invalid group length in group 4: expected 12, found 8 invalid group length in group 4: expected 12, found 10 ``` ## Suspected cause The final group length seems to be incorrectly calculated. For URN inputs, the reported value seems to include the 9-character `urn:uuid:` prefix. ```text 15 + 9 = 24 8 + 9 = 17 3 + 9 = 12 ``` For braced inputs, the reported value seems to include both braces. ```text 15 + 2 = 17 8 + 2 = 10 10 + 2 = 12 ```
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#881
No description provided.