GPT-5 finding
Unhandled missing OPTIN_HMAC_SECRET causes 500 instead of a friendly error
- apps/web/lib/optin-token.ts
- apps/web/app/api/opt-in/route.ts
If OPTIN_HMAC_SECRET is unset in the environment, verifyTokenDetailed() will throw inside getSecret(). The route does not catch this, yielding a 500 without a clear user-facing explanation. While this is a deploy misconfiguration, it’s better to fail with a controlled HTML response and a clear log.
Recommendation
Wrap token verification in try/catch. On error, log and return htmlResponse(500, errorPage("Server misconfigured", "...")), or validate presence of OPTIN_HMAC_SECRET at process startup to fail fast with a clear error.