Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect version shown for crates.io #9453

Open
nyurik opened this issue Aug 8, 2023 · 4 comments 路 May be fixed by #9454
Open

Incorrect version shown for crates.io #9453

nyurik opened this issue Aug 8, 2023 · 4 comments 路 May be fixed by #9454
Labels
good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs

Comments

@nyurik
Copy link

nyurik commented Aug 8, 2023

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.

@nyurik nyurik added the question Support questions, usage questions, unconfirmed bugs, discussions, ideas label Aug 8, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Aug 8, 2023

Badge tested using npm run badge https://img.shields.io/crates/l/martin.svg
Output is available here

@nyurik
Copy link
Author

nyurik commented Aug 8, 2023

See also rust-lang/crates.io#6946

@calebcartwright
Copy link
Member

Seems reasonable to me to elide any and all yanked versions

@calebcartwright calebcartwright added good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs and removed question Support questions, usage questions, unconfirmed bugs, discussions, ideas labels Aug 8, 2023
nyurik added a commit to nyurik/shields that referenced this issue Aug 8, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
@nyurik nyurik linked a pull request Aug 8, 2023 that will close this issue
@nyurik
Copy link
Author

nyurik commented Aug 8, 2023

@calebcartwright I just submitted a PR to fix this and related issue (download count) -- I simply search for the needed version in the versions array using crates's own latest stable version. Makes things far simpler I think.

nyurik added a commit to nyurik/shields that referenced this issue Aug 9, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
nyurik added a commit to nyurik/shields that referenced this issue Aug 9, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
nyurik added a commit to nyurik/shields that referenced this issue Aug 9, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
nyurik added a commit to nyurik/shields that referenced this issue Aug 11, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
nyurik added a commit to nyurik/shields that referenced this issue Aug 13, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
nyurik added a commit to nyurik/shields that referenced this issue Aug 28, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
nyurik added a commit to nyurik/shields that referenced this issue Oct 30, 2023
For download count and license, get the correct latest version from the versions array.

Fix badges#9453
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue New contributors, join in! service-badge Accepted and actionable changes, features, and bugs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants