Skip to content

Commit e0f886e

Browse files
authored
fix(ci): surface refresh-baselines HTTP error body and status code (#161)
* fix(ci): surface refresh-baselines HTTP error body and status code Replace `curl -s -f` (silent + fail-no-body) with explicit HTTP code capture and response body dump. Workflow has been failing every 6h with exit 22 (HTTP >=400) but root cause was hidden. Next failure will print HTTP status + Supabase error message in logs. * fix(ci): harden refresh-baselines step against curl/HTTP edge cases Address CodeRabbit review feedback on PR #161: - Add EXIT trap to clean up mktemp response file - Capture curl exit code; surface clear error when curl fails before producing an HTTP code (DNS, TLS, connection reset) - Validate http_code is numeric before integer comparison to avoid obscure "integer expression expected" failure - Only dump response body on HTTP >=400 to avoid noisy logs and reduce risk of leaking verbose payloads on success
1 parent c159293 commit e0f886e

1 file changed

Lines changed: 22 additions & 2 deletions

File tree

.github/workflows/refresh-baselines.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,28 @@ jobs:
1414
ANON_KEY: ${{ secrets.SUPABASE_ANON_KEY }}
1515
SECRET: ${{ secrets.REFRESH_SECRET }}
1616
run: |
17-
curl -s -f -X POST \
17+
response=$(mktemp)
18+
trap 'rm -f "${response}"' EXIT
19+
curl_exit=0
20+
http_code=$(curl -sS -X POST \
21+
-o "${response}" \
22+
-w "%{http_code}" \
1823
"${FUNCTION_URL}/refresh-baselines" \
1924
-H "Authorization: Bearer ${ANON_KEY}" \
2025
-H "x-refresh-secret: ${SECRET}" \
21-
-H "Content-Type: application/json"
26+
-H "Content-Type: application/json") || curl_exit=$?
27+
if [ "${curl_exit}" -ne 0 ]; then
28+
echo "curl failed before producing an HTTP response (exit ${curl_exit})"
29+
exit 1
30+
fi
31+
if ! [[ "${http_code}" =~ ^[0-9]+$ ]]; then
32+
echo "Invalid HTTP code: ${http_code:-<empty>}"
33+
exit 1
34+
fi
35+
echo "HTTP ${http_code}"
36+
if [ "${http_code}" -ge 400 ]; then
37+
echo "Response body:"
38+
cat "${response}"
39+
echo
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)