Skip to content

Commit 908d49b

Browse files
JohnRDOrazioclaude
andcommitted
fix: handle non-array WordPress API responses in deploy workflow
The WP REST API can return an error object instead of an array when querying pages by slug. Guard jq expressions with type checks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 8868c5e commit 908d49b

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

.github/workflows/deploy-docs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ jobs:
129129
PARENT_PAGE=$(curl -s \
130130
-u "$WP_APP_USERNAME:$WP_APP_PASSWORD" \
131131
"$WP_REST_URL/wp/v2/pages?slug=${PARENT_SLUG}&status=publish,draft")
132-
PID=$(echo "$PARENT_PAGE" | jq -r '.[0].id // empty')
132+
PID=$(echo "$PARENT_PAGE" | jq -r 'if type == "array" then .[0].id // empty else empty end')
133133
if [ -n "$PID" ] && [ "$PID" != "null" ]; then
134134
PARENT_IDS[$PARENT_SLUG]="$PID"
135135
echo " Resolved parent '${PARENT_SLUG}' (ID: $PID)"
@@ -147,7 +147,7 @@ jobs:
147147
-u "$WP_APP_USERNAME:$WP_APP_PASSWORD" \
148148
"$WP_REST_URL/wp/v2/pages?slug=${SLUG}&status=publish,draft")
149149
150-
PAGE_ID=$(echo "$EXISTING" | jq -r '.[0].id // empty')
150+
PAGE_ID=$(echo "$EXISTING" | jq -r 'if type == "array" then .[0].id // empty else empty end')
151151
152152
PAYLOAD=$(jq -n \
153153
--arg title "$TITLE" \

0 commit comments

Comments
 (0)