Skip to content

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

@ktwrd

Description

@ktwrd

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.

{
  "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<String, TValue>
  2. Trim any 0 at start of key
  3. Parse key as usize
  4. Return new hashmap with type HashMap<usize, TValue>

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

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions