From 51f97c724bd8f305496803c82b0d9a3ebf4e3a48 Mon Sep 17 00:00:00 2001 From: adilallo <39313955+adilallo@users.noreply.github.com> Date: Mon, 23 Nov 2026 13:52:53 -0700 Subject: [PATCH] Skip optional Umami and a hidden rule-counts route in staging smoke. Unconfigured hosts were failing checks that only apply once an admin, ops token, or tracker is set. --- docs/guides/ops-runbook.md | 9 ++++++++- scripts/staging-smoke.sh | 22 ++++++++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/guides/ops-runbook.md b/docs/guides/ops-runbook.md index 21fdfbf..449cfde 100644 --- a/docs/guides/ops-runbook.md +++ b/docs/guides/ops-runbook.md @@ -147,8 +147,15 @@ mount). # optional — exercises magic-link request (check inbox manually): EMAIL=you@example.com ./scripts/staging-smoke.sh staging.communityrule.info + +# optional — require the Umami tracker, and check rule-counts with the bearer token: +EXPECT_UMAMI=1 OPS_PRUNE_TOKEN=... ./scripts/staging-smoke.sh staging.communityrule.info ``` +Logged-out rule-counts may be 401 (route live) or 404 (hidden until +`RULE_ADMIN_EMAILS` or `OPS_PRUNE_TOKEN` is set). A missing Umami tag is +skipped unless `EXPECT_UMAMI=1`. + **Manual** (still required for full acceptance): - Click a magic link → signed in → `GET /api/auth/session` returns a user. @@ -267,7 +274,7 @@ Full detail: [`ops-backend-deploy.md` §3](ops-backend-deploy.md#3-environment-v | Container crash on start | Migration failure | App logs around `prisma migrate deploy`; fix forward with new migration | | Magic link not sent | Mail addon, `SMTP_FROM`, or SES DNS | Cloudron mail logs (`CLOUDRON_MAIL_SMTP_*`); inbox/spam; SPF/DKIM for SES (§8.1) | | Upload `server_misconfigured` | `UPLOAD_ROOT` unset | `cloudron env set --app UPLOAD_ROOT=/app/data/uploads` | -| `/api/ops/rule-counts` is 404 | Neither `RULE_ADMIN_EMAILS` nor `OPS_PRUNE_TOKEN` is set | Set both. Strangers then get 401; a named admin or the bearer token gets 200. | +| `/api/ops/rule-counts` is 404 | Neither `RULE_ADMIN_EMAILS` nor `OPS_PRUNE_TOKEN` is set | Set at least one. Strangers then get 401; a named admin or the bearer token gets 200. | | No Umami script in the HTML | Tracker env unset, or cookies still on in Umami | Install Umami with `--no-sso` (§9.3), turn cookies off, set both `NEXT_PUBLIC_UMAMI_*` vars | | No “Recommended” on method cards | Seed not run | §3.4 — `node prisma/seed.bundle.cjs` | | Rate limit too aggressive after deploy | Expected per §6.1 | Single instance only; limits reset on container restart | diff --git a/scripts/staging-smoke.sh b/scripts/staging-smoke.sh index 13b0769..bf2eaf6 100755 --- a/scripts/staging-smoke.sh +++ b/scripts/staging-smoke.sh @@ -7,6 +7,7 @@ # ./scripts/staging-smoke.sh communityrule.info # EMAIL=you@example.com ./scripts/staging-smoke.sh staging.communityrule.info # OPS_PRUNE_TOKEN=... ./scripts/staging-smoke.sh # also checks /api/ops/rule-counts with the bearer token +# EXPECT_UMAMI=1 ./scripts/staging-smoke.sh # fail if the homepage has no Umami tracker # # Manual follow-up (not automated here): click magic link in inbox, publish a rule, # optional upload with UPLOAD_ROOT set. @@ -68,7 +69,22 @@ check_json_contains 'templates seeded (non-empty)' '"slug":' check_http "GET /api/rules" "$BASE/api/rules" "200" check_json_contains 'rules list shape' '"rules":[' -check_http "GET /api/ops/rule-counts (logged out)" "$BASE/api/ops/rule-counts" "401" +# 401: route is live and the caller is logged out. +# 404: hidden because neither RULE_ADMIN_EMAILS nor OPS_PRUNE_TOKEN is set. +# A supplied OPS_PRUNE_TOKEN means the route should exist, so 404 fails. +status="$(curl -sS -o /tmp/staging-smoke-body.$$ -w '%{http_code}' \ + "$BASE/api/ops/rule-counts" || echo '000')" +if [ "$status" = "401" ]; then + pass "GET /api/ops/rule-counts (logged out) (HTTP 401)" +elif [ "$status" = "404" ] && [ -z "${OPS_PRUNE_TOKEN:-}" ]; then + printf 'SKIP GET /api/ops/rule-counts (logged out) (HTTP 404, hidden until RULE_ADMIN_EMAILS or OPS_PRUNE_TOKEN is set)\n' +else + fail "GET /api/ops/rule-counts (logged out) (expected HTTP 401, got $status)" + if [ -f "/tmp/staging-smoke-body.$$" ]; then + head -c 500 "/tmp/staging-smoke-body.$$" 1>&2 || true + printf '\n' 1>&2 + fi +fi if [ -n "${OPS_PRUNE_TOKEN:-}" ]; then status="$(curl -sS -o /tmp/staging-smoke-body.$$ -w '%{http_code}' \ @@ -89,8 +105,10 @@ fi check_http "GET / (homepage)" "$BASE/" "200" if grep -Fq 'data-website-id' "/tmp/staging-smoke-body.$$" 2>/dev/null; then pass "Umami tracker on homepage" -else +elif [ "${EXPECT_UMAMI:-}" = "1" ]; then fail "Umami tracker on homepage (missing data-website-id)" +else + printf 'SKIP Umami tracker on homepage (optional; set EXPECT_UMAMI=1 to require data-website-id)\n' fi if [ -n "${EMAIL:-}" ]; then