fix(ci): use GET for rerun freshness check#354
Conversation
imbajin
left a comment
There was a problem hiding this comment.
Blocking: yes. Summary: The explicit GET fixes the request method, but the new error handling breaks the intended branch-deleted skip path. Evidence: querying the commits endpoint for a missing branch returns HTTP 404 with exit code 1, which terminates this set -euo pipefail step before the fallback runs.
| reason="missing head repository metadata" | ||
| else | ||
| latest_head_sha="$(gh api "repos/$HEAD_REPOSITORY/commits" -f sha="$HEAD_BRANCH" -F per_page=1 --jq '.[0].sha' 2>/dev/null || true)" | ||
| latest_head_sha="$(gh api --method GET "repos/$HEAD_REPOSITORY/commits" -f sha="$HEAD_BRANCH" -F per_page=1 --jq '.[0].sha')" |
There was a problem hiding this comment.
set -euo pipefail. When the source branch has been deleted or is inaccessible, this GET returns HTTP 404 with exit code 1, so the step exits here and never reaches the intended action="skip" / reason="head branch no longer available" handling below. Please keep --method GET, but capture the command failure explicitly (for example with an if ! latest_head_sha="$(...)"; then ... fi) and convert the expected branch-gone case into a safe skip without allowing the error response into $GITHUB_OUTPUT.
imbajin
left a comment
There was a problem hiding this comment.
Blocking: no. Summary: The explicit GET now preserves the intended branch-unavailable skip path under set -euo pipefail, with no remaining actionable findings. Evidence: three independent review lanes, static shell control-flow verification, and all visible latest-head checks are green. Score: 9.3/10.
Purpose of the PR
Main Changes
Root Cause
The
gh apicommand included-fand-Fparameters without specifying an HTTP method. GitHub CLI therefore switched the request from GET to POST, causing the commits endpoint to return404 Not Found.The error response was assigned to
latest_head_shaand subsequently written to$GITHUB_OUTPUT, producing the following error:As a result, the workflow failed at the
Check source branch freshnessstep beforegh run reruncould be executed.Previous Failures
The same error can be found in the following Rerun CI runs:
Add --method GET to the source branch freshness API request.
Ensure the sha and per_page parameters are sent as GET query parameters.
Verifying these changes
Does this PR potentially affect the following parts?
Documentation Status
Doc - TODODoc - DoneDoc - No Need