From 272c4b315f9c7fe2c4ce2f1c0f26c57954e5569c Mon Sep 17 00:00:00 2001 From: Lucas Carlson Date: Thu, 8 Oct 2026 00:38:42 -0700 Subject: [PATCH 1/2] ci: treat a too-early Context7 refresh as a skip The first run of the refresh workflow failed. curl timed out after 60 seconds with no response, and later calls returned HTTP 400 {"error":"too-early","message":"... Minimum 10 days required between updates."}. Context7 limits how often one library refreshes, so the workflow failed on most pushes to main. Allow 180 seconds for the response, print the body, and end with a workflow notice when Context7 answers too-early. Any other non-200 answer still fails the job. Against the live API, the old script exited 56 on the too-early answer and the new script exits 0 with the notice. --- .github/workflows/context7-refresh.yml | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/.github/workflows/context7-refresh.yml b/.github/workflows/context7-refresh.yml index a112ed8..05732b2 100644 --- a/.github/workflows/context7-refresh.yml +++ b/.github/workflows/context7-refresh.yml @@ -23,8 +23,19 @@ jobs: CONTEXT7_API_KEY: ${{ secrets.CONTEXT7_API_KEY }} LIBRARY_NAME: /${{ github.repository }} run: | - curl --fail --silent --show-error --max-time 60 \ + status=$(curl --silent --show-error --max-time 180 --output response.json --write-out '%{http_code}' \ -X POST https://context7.com/api/v1/refresh \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $CONTEXT7_API_KEY" \ - -d "{\"libraryName\": \"$LIBRARY_NAME\"}" + -d "{\"libraryName\": \"$LIBRARY_NAME\"}") + cat response.json + echo + if [ "$status" = "200" ]; then + exit 0 + fi + if [ "$status" = "400" ] && grep -q '"error":"too-early"' response.json; then + echo "::notice::Context7 refreshed $LIBRARY_NAME recently, so it skipped this refresh." + exit 0 + fi + echo "::error::Context7 refresh failed with HTTP $status." + exit 1 From 83629000e184fa3c29b4d1f294a14d6a13465242 Mon Sep 17 00:00:00 2001 From: Lucas Carlson Date: Thu, 8 Oct 2026 00:54:34 -0700 Subject: [PATCH 2/2] ci: read the Context7 error field with jq Review feedback on solid-objects-js#65. The too-early check matched the exact string "error":"too-early", so valid JSON with other spacing, such as {"error": "too-early"}, would fail the job instead of skipping. Read the field with jq. On four sample bodies, grep missed the spaced form and jq skipped it, and both still fail on another error and on a body that is not JSON. Against the live API the workflow script still exits 0 with the notice. --- .github/workflows/context7-refresh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/context7-refresh.yml b/.github/workflows/context7-refresh.yml index 05732b2..17d0057 100644 --- a/.github/workflows/context7-refresh.yml +++ b/.github/workflows/context7-refresh.yml @@ -33,7 +33,7 @@ jobs: if [ "$status" = "200" ]; then exit 0 fi - if [ "$status" = "400" ] && grep -q '"error":"too-early"' response.json; then + if [ "$status" = "400" ] && jq -e '.error == "too-early"' response.json > /dev/null; then echo "::notice::Context7 refreshed $LIBRARY_NAME recently, so it skipped this refresh." exit 0 fi