Skip to content

Commit bad849d

Browse files
committed
Fix 404 response body breaking tag existence check
gh api prints the 404 JSON response body to stdout even on failure. The previous command $(gh api ... 2>/dev/null || echo "") only suppressed stderr and prevented exit code propagation, but the 404 body was still captured into EXISTING_JSON, making the -n test pass and causing node to throw a TypeError on .object.sha. Split the assignment from the fallback so that on non-zero exit, EXISTING_JSON is explicitly overwritten to empty string.
1 parent 7e12956 commit bad849d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

.github/workflows/provenance.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ jobs:
258258
TAG="v$PUBLISHED_VERSION"
259259
260260
# Look up any existing tag via the API. 200 → exists; 404 → absent.
261-
EXISTING_JSON=$(gh api "repos/$REPO/git/ref/tags/$TAG" 2>/dev/null || echo "")
261+
EXISTING_JSON=$(gh api "repos/$REPO/git/ref/tags/$TAG" 2>/dev/null) || EXISTING_JSON=""
262262
if [ -n "$EXISTING_JSON" ]; then
263263
EXISTING_SHA=$(echo "$EXISTING_JSON" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).object.sha")
264264
if [ "$EXISTING_SHA" = "$PUBLISHED_SHA" ]; then

0 commit comments

Comments
 (0)