Error message when trying to parse a random string as a UUID is not helpful #499

Closed
opened 2020-11-23 11:13:29 -06:00 by jplatte · 2 comments
jplatte commented 2020-11-23 11:13:29 -06:00 (Migrated from github.com)

Describe the bug

When trying to deserialize something that should contain a UUID, but contains some other string that doesn't happen to be 32 or 36 characters long, one gets this error message from serde:

invalid length: expected one of [36, 32], found <something>

This is very unhelpful.

Expected behavior

I would expect the error to state that UUID parsing failed. The fact that it failed at a length check would be nice to have as a detail, but is far less important.

Other

I think a good fix for this would be to change the serde code to wrap the UUID parsing error in format!("UUID parsing failed: {}", e) or something like that. If you want, I'll open a PR.

**Describe the bug** When trying to deserialize something that should contain a UUID, but contains some other string that doesn't happen to be 32 or 36 characters long, one gets this error message from serde: `invalid length: expected one of [36, 32], found <something>` This is very unhelpful. **Expected behavior** I would expect the error to state that UUID parsing failed. The fact that it failed at a length check would be nice to have as a detail, but is far less important. **Other** I think a good fix for this would be to change the serde code to wrap the UUID parsing error in `format!("UUID parsing failed: {}", e)` or something like that. If you want, I'll open a PR.
KodrAus commented 2020-12-21 01:22:55 -06:00 (Migrated from github.com)

This sounds like a nice improvement to me! Would you be happy to submit a PR @jplatte?

This sounds like a nice improvement to me! Would you be happy to submit a PR @jplatte?
jplatte commented 2020-12-21 02:58:02 -06:00 (Migrated from github.com)

Will do.

Will do.
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#499
No description provided.