fix: health endpoint crashes when Supabase env vars are missing (#36)#41
Closed
zacharias-ona wants to merge 1 commit into
Closed
fix: health endpoint crashes when Supabase env vars are missing (#36)#41zacharias-ona wants to merge 1 commit into
zacharias-ona wants to merge 1 commit into
Conversation
Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
Closing as duplicate. The identical fix was already merged via PR #40 (commit |
Collaborator
Author
|
Review — no blocking issues found.
|
Collaborator
Author
zacharias-ona
added a commit
that referenced
this pull request
Apr 15, 2026
The PULL_REQUEST_EVENT_MERGED webhook and */10 cron can fire simultaneously, spawning two agents that both pick the same issue before either marks it in-progress. This caused duplicate PRs for issues #26 (PRs #45/#46) and #36 (PRs #40/#41). The cron alone ensures work is picked up within 10 minutes. Co-authored-by: Ona <no-reply@ona.com>
This was referenced Apr 15, 2026
zacharias-ona
added a commit
that referenced
this pull request
Apr 15, 2026
The PULL_REQUEST_EVENT_MERGED webhook and */10 cron can fire simultaneously, spawning two agents that both pick the same issue before either marks it in-progress. This caused duplicate PRs for issues #26 (PRs #45/#46) and #36 (PRs #40/#41). The cron alone ensures work is picked up within 10 minutes. Co-authored-by: Ona <no-reply@ona.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #36
What
The health endpoint (
GET /api/health) reported{"status":"down","db":{"connected":false,"latency_ms":0}}when Supabase environment variables were not configured in Vercel. The route handler calledcreateClient()without checking whetherNEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEYwere set. The non-null assertions (!) silently passedundefinedtocreateServerClient, which threw when making the HTTP request. Thecatchblock then reported the database as "down" — misleading, since the database was never reached.How
Added an env var guard at the top of the health route handler, matching the pattern already used in
src/proxy.ts. When Supabase env vars are missing, the endpoint returns{"status":"ok","db":{"connected":false,"latency_ms":0,"reason":"not_configured"}}instead of crashing into the catch block. The overall app status remains "ok" since the app itself is running — only the DB connection is absent.Also updated
.agents/conventions.mdwith the env var guard pattern (placed next to the API routes section) to prevent the same class of bug in future route handlers.Testing
Added 6 regression tests in
src/app/api/health/route.test.ts:not_configured(would have caught this bug)not_configuredRun:
pnpm test -- src/app/api/health/route.test.ts