Repository navigation
fix: fetch the pin release manifest via gh api - #14
nullPointerEnjoyer wants to merge 1 commit into
Conversation
|
🔍 OpenCodeReview found 3 issue(s) in this PR.
|
| asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \ | ||
| --jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \ | ||
| || asset_url="" |
There was a problem hiding this comment.
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:
| 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="" |
| asset_url="$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${head_tag}" \ | ||
| --jq '.assets[] | select(.name == "SHA256SUMS") | .url' 2>/dev/null)" \ | ||
| || asset_url="" |
There was a problem hiding this comment.
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:
| 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="" |
| 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 |
There was a problem hiding this comment.
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:
| 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 |
|
Closing in favor of folding this fix into the pin PR (#13) so it carries everything it needs to pass in one shot. |
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 apiinterface: 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.