Skip to content

fix: fetch the pin release manifest via gh api - #14

Closed
nullPointerEnjoyer wants to merge 1 commit into
mainfrom
fix/gate-release-api
Closed

nullPointerEnjoyer wants to merge 1 commit into
mainfrom
fix/gate-release-api

Conversation

@nullPointerEnjoyer

Copy link
Copy Markdown
Collaborator

The pin-order gate's SHA256SUMS fetch used gh release download --pattern --output -, which the runner's gh build rejects (same old-gh class as the --paginate failure in #12) — fail-closed, which is why PR #13's "Pin ordering" check is red.

Rewrites the fetch over the stable gh api interface: resolve the SHA256SUMS asset URL from the release, then fetch it with Accept: application/octet-stream. No behavior change otherwise; fail-closed paths preserved (missing asset and unreadable manifest each keep their own annotation).

Suite 159 assertions green, shellcheck clean. After this merges, PR #13's failed check re-runs against the fixed base and the pin proceeds.

@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

🔍 OpenCodeReview found 3 issue(s) in this PR.

  • ✅ Successfully posted inline: 3 comment(s)

Comment on lines +99 to +101
asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \
--jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \
|| asset_url=""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

bug · medium
If the release ever carries more than one asset named SHA256SUMS, --jq emits multiple lines and asset_url becomes a multi-line string. The subsequent gh api "${asset_url}" then receives an invalid/multi-line path argument, so the manifest fetch will fail (or misbehave) with a misleading error instead of failing closed with a clear message. Either take the first match explicitly or fail when the count is not exactly 1.

Suggestion:

Suggested change
asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \
--jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \
|| asset_url=""
asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \
--jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null | head -n1)" \
|| asset_url=""

Comment on lines +99 to +101
asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \
--jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \
|| asset_url=""

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

maintainability · medium
The new code introduces a hard dependency on GITHUB_REPOSITORY (used in the gh api path), but the environment contract documented in the header comment (lines 20-21) is not updated to list it. Under set -u, an unset GITHUB_REPOSITORY aborts with a bare "unbound variable" error instead of the structured ::error:: fail-closed message the rest of the script produces. Consider defaulting it (e.g. GITHUB_REPOSITORY="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY required}" near the other required vars) and updating the header's Environment section.

Suggestion:

Suggested change
asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \
--jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \
|| asset_url=""
GITHUB_REPOSITORY="${GITHUB_REPOSITORY:?GITHUB_REPOSITORY required}"
...
asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \
--jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \
|| asset_url=""

Comment on lines +89 to 92
if [ "$1" = "api" ]; then
[ "$(cat "${CASE_DIR}/release_download_fails" 2>/dev/null || echo 0)" = "1" ] && exit 1
cat "${CASE_DIR}/release_sums"
exit 0

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

test · medium
The stub treats both gh api invocations identically: the first call (the releases/tags metadata query expecting an asset URL from --jq) receives the contents of release_sums instead of a URL. As a result the two-call contract (metadata query -> octet-stream asset download) is never actually exercised — the test would still pass even if the gate script wrongly fetched the sums directly, and the multiline-asset edge case goes undetected. Consider having the stub emit a canned asset URL on the first call (e.g. when args contain --jq) and serve release_sums only on the second call.

Suggestion:

Suggested change
if [ "$1" = "api" ]; then
[ "$(cat "${CASE_DIR}/release_download_fails" 2>/dev/null || echo 0)" = "1" ] && exit 1
cat "${CASE_DIR}/release_sums"
exit 0
if [ "$1" = "api" ]; then
[ "$(cat "${CASE_DIR}/release_download_fails" 2>/dev/null || echo 0)" = "1" ] && exit 1
if [ "$2" = "--jq" ]; then
echo "https://api.github.com/repos/mintlayer/rust-sdk/releases/assets/1"
else
cat "${CASE_DIR}/release_sums"
fi
exit 0

@nullPointerEnjoyer

Copy link
Copy Markdown
Collaborator Author

Closing in favor of folding this fix into the pin PR (#13) so it carries everything it needs to pass in one shot.

@nullPointerEnjoyer
nullPointerEnjoyer deleted the fix/gate-release-api branch November 24, 2026 16:25
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