Skip to content

Incorrect version shown for crates.io #9453

@nyurik

Description

@nyurik

Are you experiencing an issue with...

shields.io

🐞 Description

The martin crate, currently at v0.8.7, at one point published a v1.0.0-alpha version that was later yanked. The crates.io API returns versions in semver-DESC order, which means the yanked alpha version is accessed as the most recent one by this code (license access). As the result, instead of showing correct license info, it shows obsolete and non-refreshing data.

const license = version ? version.license : versions[0].license

Relevant portion of the API response for https://crates.io/api/v1/crates/martin

{
  "versions": [
    {
      "created_at": "2021-10-18T13:32:02.600041+00:00",
      "num": "1.0.0-alpha.0",
      "license": "non-standard",
      "updated_at": "2022-11-21T03:56:25.244956+00:00",
      "yanked": true
    },
    {
      "created_at": "2023-06-23T04:05:38.815265+00:00",
      "num": "0.8.7",
      "license": "MIT OR Apache-2.0",
      "updated_at": "2023-06-23T04:05:38.815265+00:00",
      "yanked": false
    }
  ]
}

🔗 Link to the badge

https://img.shields.io/crates/l/martin.svg

💡 Possible Solution

I believe it would be better to pick the first non-yanked version from the array instead, plus probably parse the version value and ignore all the pre-released too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions