Fix the preview reaper: it never actually read a PR state - #69
Merged
Conversation
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.
Contributor
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The reaper merged in #68 fails on the first preview directory it inspects:
Cause
gh api --include --silent "repos/$REPOSITORY/pulls/$pr_number"--includeasks for the response headers,--silentsuppresses the response body. Together they write a file containing headers and no JSON, sojq -r .statereturns empty and the script exits 1.Confirmed by running both forms against the live API:
.stategh api --include --silent .../pulls/67gh api --include .../pulls/67openThe 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 printedwould delete: nonewithout 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.