Format-specific UUID parsers can report incorrect error diagnostics #880
Labels
No labels
breaking
bug
dependencies
good first issue
help wanted
unstable
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-uuid-rs/uuid#880
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When parsing UUIDs through format-specific types, some invalid inputs produce incorrect error diagnostics.
Reproduction
Output:
Expected behavior
The parsers should still reject these inputs. However, a format-specific parser should not report an error as if a different UUID format had been requested. The diagnostic should also not report equal expected and actual values, such as
expected 12, found 12.Suspected cause
github.com/uuid-rs/uuid@ca0c85fe21/src/fmt.rs (L871-L909)The format-specific parsers call their corresponding strict parser first, then convert the lightweight parse failure through
InvalidUuid::into_err().InvalidUuid::into_err()re-analyzes the input string generically in order to construct a detailed Error. As a result, the generated diagnostic may be based on a perspective other than the originally requested format, which can lead to inaccurate error reporting.