Skip to content

fix(ci): use GET for rerun freshness check#354

Merged
imbajin merged 2 commits into
apache:masterfrom
lokidundun:fixci
Jul 15, 2026
Merged

fix(ci): use GET for rerun freshness check#354
imbajin merged 2 commits into
apache:masterfrom
lokidundun:fixci

Conversation

@lokidundun

Copy link
Copy Markdown
Contributor

Purpose of the PR

  • close #xxx

Main Changes

Root Cause

The gh api command included -f and -F parameters without specifying an HTTP method. GitHub CLI therefore switched the request from GET to POST, causing the commits endpoint to return 404 Not Found.

The error response was assigned to latest_head_sha and subsequently written to $GITHUB_OUTPUT, producing the following error:

Unable to process file command 'output' successfully.
Invalid format '  "message": "Not Found",\r'

As a result, the workflow failed at the Check source branch freshness step before gh run rerun could 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

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows.

Does this PR potentially affect the following parts?

  • Nope
  • Dependencies (add/update license info)
  • Modify configurations
  • The public API
  • Other affects (typed here)

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jul 14, 2026

@imbajin imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

Comment thread .github/workflows/rerun-ci.yml Outdated
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')"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

⚠️ This removes the failure guard from a command substitution that runs under 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 imbajin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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.

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Jul 15, 2026
@imbajin imbajin merged commit a6b2fb2 into apache:master Jul 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants