ktwrd / ktwrd/beans-rs

[Bug] Cannot parse into usize when remote bullseye@v1 has leading zeros

Open
#46 0 comments 0 reactions 1 assignee Claimed by @ktwrd View on GitHub
bug
Dominant language
Rust
Stars
11
Forks
2
Avg merge
6m
Merged PRs (30d)
2

Description

`beans-rs` fails to parse keys for the `versions` and `patches` dictionaries/hashmaps in the remote bullseye file into a `usize` when it has leading zeroes (like: `074`).

This can easily be reproduced by having any key in the `versions` or `patches` hashmap/dictionary with leading zeros.
```json
{
"versions": {
"074": {
"file": "pf2-0.7.4.tar.zst",
"presz": 3553518945,
"postsz": 6512259072,
"signature": "pf2-0.7.4.sig",
"heal": "pf2-0.7.4-heal.zip"
}
}
}
```

Writing a fix like the following steps should fix this issue:
1. Parse into HashMap
2. Trim any `0` at start of key
3. Parse key as `usize`
4. Return new hashmap with type `HashMap`

Returning an error when a number has leading zeros is intended in `serde`, which is annoying.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.