fix: use .versions | keys | last for deterministic latest MC version#73
fix: use .versions | keys | last for deterministic latest MC version#73
Conversation
The Fill v3 API returns .versions as an object (keys = MC version strings), not an array. Using `keys | last` yields the lexicographically highest (= newest) version reliably. Fixes broken `.versions | last` (was null on object input) and the non-deterministic `keys_unsorted[0]` variant.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 417bcdac6c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| FILL_API="https://fill.papermc.io/v3/projects/paper" | ||
|
|
||
| LATEST_VERSION=$(curl -fsSL -H "User-Agent: ${USER_AGENT}" "${FILL_API}" | jq -r '.versions | last') | ||
| LATEST_VERSION=$(curl -fsSL -H "User-Agent: ${USER_AGENT}" "${FILL_API}" | jq -r '.versions | keys | last') |
There was a problem hiding this comment.
Use semantic version ordering for latest lookup
jq '.versions | keys | last' chooses the lexicographically largest key, not the newest Minecraft version; with version strings this can select older releases (for example 1.9.x compares greater than 1.21.x as plain text). In environments where Paper exposes multiple historical versions, this will download and run an outdated server instead of the latest stable release, so the version selection needs semantic ordering (or API-provided ordering) rather than string-key ordering.
Useful? React with 👍 / 👎.
|
Fixed directly on Note: The Codex bot raised a valid concern about |
keys | last is lexicographic and fails for e.g. 1.9 > 1.21 as strings. Use jq semver sort: split on '.', map to numbers, sort, take last. Fixes Codex review comment on PR #73.
The Fill v3 API returns .versions as an object (keys = MC version strings), not an array. Using
keys | lastyields the lexicographically highest (= newest) version reliably. Fixes broken.versions | last(was null on object input) and the non-deterministickeys_unsorted[0]variant.Pull Request – Simulation Only
Summary
Describe what this PR changes (scripts, docs). No commands are executed in this workspace.
Checklist
SIMULATION.mdupdated to reflect behavior and risks.Testing (Simulation)
Explain expected side effects if run on a proper host (files created, services started, ports opened). Include rollback/cleanup notes.