Skip to content

fix: use .versions | keys | last for deterministic latest MC version#73

Closed
TimInTech wants to merge 1 commit intomainfrom
Justahobby01/patch-1
Closed

fix: use .versions | keys | last for deterministic latest MC version#73
TimInTech wants to merge 1 commit intomainfrom
Justahobby01/patch-1

Conversation

@TimInTech
Copy link
Copy Markdown
Owner

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.

Pull Request – Simulation Only

Summary

Describe what this PR changes (scripts, docs). No commands are executed in this workspace.

Checklist

  • No commands executed locally; all steps are simulated/explained only.
  • Changes are limited to scripts and/or documentation.
  • SIMULATION.md updated to reflect behavior and risks.
  • If adding a new script or option, included example usage commands (chmod +x; ./script; screen -r ...).
  • Security considerations addressed (least-privilege user, ports, backups).

Testing (Simulation)

Explain expected side effects if run on a proper host (files created, services started, ports opened). Include rollback/cleanup notes.

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.
@TimInTech TimInTech closed this in f8cca25 May 1, 2026
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread setup_minecraft_lxc.sh
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')
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@TimInTech
Copy link
Copy Markdown
Owner Author

Fixed directly on main in f8cca25. Thanks for the contribution!

Note: The Codex bot raised a valid concern about keys | last using lexicographic instead of semantic version ordering (e.g. 1.9.x > 1.21.x as strings). This has been addressed in a follow-up commit using proper semantic version sorting via jq.

TimInTech added a commit that referenced this pull request May 1, 2026
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.
@TimInTech TimInTech deleted the Justahobby01/patch-1 branch May 1, 2026 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant