Skip to content

Fix the preview reaper: it never actually read a PR state - #69

Merged
isaaclins merged 1 commit into
mainfrom
fix/reaper-api-body
Aug 5, 2026
Merged

Fix the preview reaper: it never actually read a PR state#69
isaaclins merged 1 commit into
mainfrom
fix/reaper-api-body

Conversation

@isaaclins

Copy link
Copy Markdown
Owner

The reaper merged in #68 fails on the first preview directory it inspects:

::error::GitHub API returned no pull request state for PR #67
::error::Process completed with exit code 1

Cause

gh api --include --silent "repos/$REPOSITORY/pulls/$pr_number"

--include asks for the response headers, --silent suppresses the response body. Together they write a file containing headers and no JSON, so jq -r .state returns empty and the script exits 1.

Confirmed by running both forms against the live API:

Command .state
gh api --include --silent .../pulls/67 (empty)
gh api --include .../pulls/67 open

The 404 path still works without --silent, verified against a nonexistent PR number, so the missing-PR branch is unaffected.

Why it shipped

The only dry run was executed while pr-preview/ did not exist, so it printed would delete: none without ever entering the loop that calls the API. The passing check covered the empty case only.

Impact if left

The daily cron fails every day and no preview is ever reaped, which is the exact accumulation problem #68 set out to fix.

gh api --include --silent prints the response headers and suppresses the
body, so the file the reaper parsed held no JSON at all. jq found no
.state, and the script exited 1 on the first preview it looked at. The
daily cron would have failed every day.

This was not caught because the only dry run happened while pr-preview/
did not exist, so the branch that talks to the API never executed.
Copilot AI lite review requested due to automatic review settings August 5, 2026 07:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.
2026-08-05 07:45 UTC

@isaaclins
isaaclins merged commit 82f8dbf into main Aug 5, 2026
2 checks passed
@isaaclins
isaaclins deleted the fix/reaper-api-body branch August 5, 2026 07:44
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.

2 participants