feat(github): use release latest endpoint to get latest release#8516
feat(github): use release latest endpoint to get latest release#8516
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request optimizes fetching the latest release from GitHub and Forgejo by using the /releases/latest endpoint. While this is a good improvement, it introduces an insecure caching pattern in the GitHub backend and utilizes an existing vulnerable credential-handling function in the Forgejo backend. Specifically, the GitHub cache key lacks the API URL, leading to collisions between different GitHub instances, and the Forgejo backend leaks enterprise tokens to unauthorized hosts due to insufficient host verification in get_headers. The PR also includes a new implementation for latest_stable_version, corresponding API client functions, and an e2e test, with well-handled fallback mechanisms.
There was a problem hiding this comment.
Code Review
This pull request optimizes fetching the latest release from GitHub and Forgejo using the /releases/latest endpoint. However, it introduces several security concerns, including a risk of sensitive credential leakage (SSRF) due to user-controlled api_url and automatic token attachment, potential cache collisions in GitHub Enterprise due to missing api_url in the cache key, and path traversal vulnerabilities from unsanitized repository names in URL construction. Additionally, there's a caching bug affecting GitHub Enterprise users and an opportunity to refactor duplicated code for better maintainability.
|
@jdx Looks like there is an upstream issue with ✖ mise use aqua:goreleaser/goreleaser@2.14.1
mise Cannot parse Rekor public key with id cf1199155bddd051268d1f16ac5c0c75c009f6fb5a63f4177f8e18d7051e3fa0: Pkcs8 spki error : Ecdsa-P256 from der bytes to public key failed: unknown/unsupported algorithm OID: 1.2.840.10045.2.1
aqua:goreleaser/goreleaser@2.14.1 extract goreleaser_Darwin_all.tar.gz ✔
mise ~/Downloads/mise/mise.toml tools: aqua:goreleaser/goreleaser@2.14.1
❯ mise use aqua:goreleaser/goreleaser@2.14.2
aqua:goreleaser/goreleaser@2.14.2 verify GitHub artifact attestations ◡
mise ERROR Failed to install aqua:goreleaser/goreleaser@2.14.2: No GitHub artifact attestations found for aqua:goreleaser/goreleaser@2.14.2, but they are expected per aqua registry configuration
mise ERROR Run with --verbose or MISE_VERBOSE=1 for more information |
|
we don't use the versions in aqua-registry at all |
|
aqua even doesn't use the PR to update the latest versions. Those PRs just notifies shunsuke the incompatibility of aqua registry for the latest version. |
Greptile SummaryThis PR optimizes Key changes:
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["latest_stable_version(config)"] --> B{offline mode?}
B -- yes --> C["return Ok(None)"]
B -- no --> D{backend type?}
D -- GitLab --> E["return latest_version(config, 'latest')"]
D -- Forgejo --> F["forgejo::get_release_for_url(api_url, repo, 'latest')"]
D -- GitHub --> G["github::get_release_for_url(api_url, repo, 'latest')"]
F --> H{HTTP GET /releases/latest}
G --> H
H -- OK --> I["tag_name from response"]
H -- Err --> J["debug log, None"]
I --> K{version_prefix match?}
J --> K
K -- matches / no prefix --> L["strip_version_prefix → return Ok(Some(version))"]
K -- no match --> M["fallback: latest_version(config, 'latest')"]
M --> N["paginated list_remote_versions"]
Last reviewed commit: bff5c4a |
There was a problem hiding this comment.
Pull request overview
This PR updates the GitHub/Forgejo backend’s “latest” resolution to use the /releases/latest API endpoint so mise latest can find the newest stable release without paging through release lists dominated by pre-releases (while keeping GitLab behavior unchanged).
Changes:
- Add
get_release_latesthelpers insrc/github.rsandsrc/forgejo.rsto call/repos/{repo}/releases/latestwith caching. - Override
UnifiedGitBackend::latest_stable_versionto prefer the latest-release endpoint for GitHub/Forgejo and fall back to the existing behavior for GitLab (and on failure). - Add an e2e assertion and an
assert_not_emptyhelper for validatingmise latestreturns output.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/github.rs |
Adds a cached helper for fetching the latest release via /releases/latest. |
src/forgejo.rs |
Adds a cached helper for fetching the latest release via /releases/latest. |
src/backend/github.rs |
Implements a GitHub/Forgejo-specific latest_stable_version using the latest-release endpoint with fallback. |
e2e/backend/test_github |
Adds an e2e check ensuring mise latest returns a non-empty result. |
e2e/assert.sh |
Adds assert_not_empty helper for e2e tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
A few things I noticed:
This comment was generated by Claude Code. |
|
The Forgejo path in async fn get_release_(api_url: &str, repo: &str, tag: &str) -> Result<ForgejoRelease> {
let url = format!("{api_url}/repos/{repo}/releases/tags/{tag}");This constructs I confirmed that Forgejo does support async fn get_release_(api_url: &str, repo: &str, tag: &str) -> Result<ForgejoRelease> {
let url = if tag == "latest" {
format!("{api_url}/repos/{repo}/releases/latest")
} else {
format!("{api_url}/repos/{repo}/releases/tags/{tag}")
};Without this, the Forgejo optimization silently 404s and falls back to the paginated path every time. This comment was generated by Claude Code. |
2258d7f to
85586c9
Compare
| #!/usr/bin/env bash | ||
|
|
||
| # Test use of release/latest endpoint for GitHub backend | ||
| assert_not_empty "mise latest github:unikraft/kraftkit" |
There was a problem hiding this comment.
Test depends on a third-party external repository
unikraft/kraftkit is an external project owned by the Unikraft community. If this repository is deleted, renamed, archived, transfers ownership, or stops publishing stable (non-prerelease) releases, this test will begin to fail in CI with no action taken by the mise project.
Consider replacing it with a repository under jdx/ (or another org controlled by mise contributors) that is guaranteed to always have stable releases. For example, jdx/mise itself always has stable releases and would be a more stable anchor for this test:
| assert_not_empty "mise latest github:unikraft/kraftkit" | |
| assert_not_empty "mise latest github:jdx/mise" |
This also aligns the test with the existing test fixtures already used elsewhere in test_github (e.g. github:jdx/mise-test-fixtures).
### 🚀 Features - **(github)** use release latest endpoint to get latest release by @roele in [#8516](#8516) - **(install)** add shared and system install directories by @jdx in [#8581](#8581) - **(vfox)** add provenance metadata to lockfile for tool plugins by @malept in [#8544](#8544) ### 🐛 Bug Fixes - **(aqua)** expose main binary when files field is empty and symlink_bins is enabled by @AlexanderTheGrey in [#8550](#8550) - **(env)** redact secrets in `mise set` listing and task-specific env by @jdx in [#8583](#8583) - **(prepare)** install config tools before running prepare steps by @jdx in [#8582](#8582) - **(task)** allow ctrl-c to interrupt tool downloads during `mise run` by @jdx in [#8571](#8571) - **(tasks)** add file task header parser support for spaces around = by @roele in [#8574](#8574) ### 📚 Documentation - **(task)** add property description for interactive by @roele in [#8562](#8562) - add missing `</bold>` closing tag by @muzimuzhi in [#8564](#8564) - rebrand site with new chef logo and warm culinary palette by @jdx in [#8587](#8587) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:alpine docker digest to de4657e by @renovate[bot] in [#8577](#8577) - update ghcr.io/jdx/mise:copr docker digest to eef29a2 by @renovate[bot] in [#8578](#8578) - update ghcr.io/jdx/mise:rpm docker digest to 5a96587 by @renovate[bot] in [#8580](#8580) - update ghcr.io/jdx/mise:deb docker digest to 464cf7c by @renovate[bot] in [#8579](#8579) ### 📦 Registry - fix flatc version test mismatch by @jdx in [#8588](#8588) ### Chore - **(registry)** skip spark test-tool by @jdx in [#8572](#8572) ### New Contributors - @AlexanderTheGrey made their first contribution in [#8550](#8550) ## 📦 Aqua Registry Updates #### New Packages (6) - [`bahdotsh/mdterm`](https://github.com/bahdotsh/mdterm) - [`callumalpass/mdbase-lsp`](https://github.com/callumalpass/mdbase-lsp) - [`facebook/ktfmt`](https://github.com/facebook/ktfmt) - [`gurgeous/tennis`](https://github.com/gurgeous/tennis) - [`tektoncd/pipelines-as-code`](https://github.com/tektoncd/pipelines-as-code) - [`weedonandscott/trolley`](https://github.com/weedonandscott/trolley) #### Updated Packages (2) - [`apple/container`](https://github.com/apple/container) - [`cocogitto/cocogitto`](https://github.com/cocogitto/cocogitto)
…8516) Use `release/latest` endpoint to fetch latest release. This is especially useful for repositories with lots of pre-releases where mise would need to fetch all pages (via undocumented `MISE_LIST_ALL_VERSIONS`) to get the latest release. Note: GitLab does not have such an endpoint and we use current behaviour. --------- Co-authored-by: mise-en-dev <release@mise.jdx.dev> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### 🚀 Features - **(github)** use release latest endpoint to get latest release by @roele in [jdx#8516](jdx#8516) - **(install)** add shared and system install directories by @jdx in [jdx#8581](jdx#8581) - **(vfox)** add provenance metadata to lockfile for tool plugins by @malept in [jdx#8544](jdx#8544) ### 🐛 Bug Fixes - **(aqua)** expose main binary when files field is empty and symlink_bins is enabled by @AlexanderTheGrey in [jdx#8550](jdx#8550) - **(env)** redact secrets in `mise set` listing and task-specific env by @jdx in [jdx#8583](jdx#8583) - **(prepare)** install config tools before running prepare steps by @jdx in [jdx#8582](jdx#8582) - **(task)** allow ctrl-c to interrupt tool downloads during `mise run` by @jdx in [jdx#8571](jdx#8571) - **(tasks)** add file task header parser support for spaces around = by @roele in [jdx#8574](jdx#8574) ### 📚 Documentation - **(task)** add property description for interactive by @roele in [jdx#8562](jdx#8562) - add missing `</bold>` closing tag by @muzimuzhi in [jdx#8564](jdx#8564) - rebrand site with new chef logo and warm culinary palette by @jdx in [jdx#8587](jdx#8587) ### 📦️ Dependency Updates - update ghcr.io/jdx/mise:alpine docker digest to de4657e by @renovate[bot] in [jdx#8577](jdx#8577) - update ghcr.io/jdx/mise:copr docker digest to eef29a2 by @renovate[bot] in [jdx#8578](jdx#8578) - update ghcr.io/jdx/mise:rpm docker digest to 5a96587 by @renovate[bot] in [jdx#8580](jdx#8580) - update ghcr.io/jdx/mise:deb docker digest to 464cf7c by @renovate[bot] in [jdx#8579](jdx#8579) ### 📦 Registry - fix flatc version test mismatch by @jdx in [jdx#8588](jdx#8588) ### Chore - **(registry)** skip spark test-tool by @jdx in [jdx#8572](jdx#8572) ### New Contributors - @AlexanderTheGrey made their first contribution in [jdx#8550](jdx#8550) ## 📦 Aqua Registry Updates #### New Packages (6) - [`bahdotsh/mdterm`](https://github.com/bahdotsh/mdterm) - [`callumalpass/mdbase-lsp`](https://github.com/callumalpass/mdbase-lsp) - [`facebook/ktfmt`](https://github.com/facebook/ktfmt) - [`gurgeous/tennis`](https://github.com/gurgeous/tennis) - [`tektoncd/pipelines-as-code`](https://github.com/tektoncd/pipelines-as-code) - [`weedonandscott/trolley`](https://github.com/weedonandscott/trolley) #### Updated Packages (2) - [`apple/container`](https://github.com/apple/container) - [`cocogitto/cocogitto`](https://github.com/cocogitto/cocogitto)
Use
release/latestendpoint to fetch latest release. This is especially useful for repositories with lots of pre-releases where mise would need to fetch all pages (via undocumentedMISE_LIST_ALL_VERSIONS) to get the latest release.Note: GitLab does not have such an endpoint and we use current behaviour.