Skip to content

fix(cron): say which thing is actually broken - #82

Merged
catomean merged 1 commit into
mainfrom
fix/cron-emails-names-its-real-cause
Aug 29, 2026
Merged

fix(cron): say which thing is actually broken#82
catomean merged 1 commit into
mainfrom
fix/cron-emails-names-its-real-cause

Conversation

@catomean

Copy link
Copy Markdown
Collaborator

/api/cron/emails returned {"error":"Database unavailable"} while the database was finepsql connects with the app's own DATABASE_URL and the schema has 25 tables.

Two messages, both naming the wrong cause for the same failure:

where said actual
route.ts "Database unavailable" hardcoded one of the workflow's two errors
cron-emails.ts "RESEND_API_KEY not configured" the key is present, 36 chars, correctly prefixed re_

isEmailConfigured() is false for two reasons, and the log only ever announced one of them. The reason that actually applied is the second: a sandbox sender — precisely the case the guard was written for.

The guard is correct and stays. Its own comment says it best: "It looks configured — the key is set, the API returns no transport error — but delivers to nobody… This shipped to production once; the guard ends the class." Refusing to mark a queue sent when the sender reaches nobody is the whole point.

What changes is only that each message names the reason that applies. Chasing Postgres for an hour because the error said "database" is the cost of a message that guesses.

Unchanged, and an operator decision: RESEND_FROM is a sandbox address, so no patient email can be delivered until a verified domain is configured in Resend. The queue is correctly left pending rather than falsely marked sent.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P

/api/cron/emails returned {"error":"Database unavailable"} while the database
was fine — psql connects with the app's own DATABASE_URL and the schema has 25
tables. The route hardcoded one of the workflow's two possible errors, so an
email-configuration failure was reported as a database failure.

The log line beside it made the same mistake in the other direction: it said
"RESEND_API_KEY not configured" while the key was present, 36 characters and
correctly prefixed re_. isEmailConfigured() is false for TWO reasons, and the
second one — a sandbox sender, which is exactly the case the guard was written
for — announced the first.

Both now name the reason that applies. The guard itself is correct and stays:
refusing to mark a queue sent when the sender reaches nobody is the whole point
of it.

The underlying condition is unchanged and is an operator decision: RESEND_FROM
is a sandbox address, so no patient email can be delivered until a verified
domain is set.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UvjGNAS9CMfEGNW26tUR4P
@catomean
catomean merged commit 721c30a into main Aug 29, 2026
1 check passed
@catomean
catomean deleted the fix/cron-emails-names-its-real-cause branch August 29, 2026 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant