You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(dev): migration 337 cannot be applied — dev is missing both vault secrets the notification cron depends on #564
Found while reconciling dev's migration ledger. Dev is now at 178/179; 337_notification_cron_vault.sql is the one deliberately-unapplied migration, and it should stay that way until this is fixed.
Why it was skipped rather than applied
337 schedules six pg_cron jobs that each net.http_post to an edge function. The URL and the auth header are read from Vault at execution time:
url := (SELECT decrypted_secret FROMvault.decrypted_secretsWHERE name ='edge_functions_url'LIMIT1) ||'/notify-send-worker'
headers := jsonb_build_object('Authorization', 'Bearer '|| (SELECT decrypted_secret FROMvault.decrypted_secretsWHERE name ='service_role_key'LIMIT1), ...)
Neither secret exists on dev. Prod has both.
edge_functions_url
service_role_key
dev
absent
absent
prod
present
present
So applying 337 to dev as it stands would schedule six jobs — one of them every minute — that resolve url to NULL and send Authorization: Bearer with nothing after it. That is strictly worse than not applying it: six broken jobs firing forever, and a ledger entry claiming the notification cron is live on dev when it is not.
pg_cron and pg_net are both installed on dev, so the migration's own graceful-skip path (IF NOT EXISTS (SELECT 1 FROM pg_available_extensions WHERE name = 'pg_cron')) would not trigger. It would run and produce the broken jobs.
Work
Create the two Vault secrets on dev: edge_functions_url (dev project's functions base URL) and service_role_key (dev service-role key).
Apply 337: ./scripts/apply-migration.sh dev 337_notification_cron_vault.sql
Confirm six rows in cron.job matching notifications-%, and check cron.job_run_details for a successful first run rather than assuming.
Not agent-ready — step 1 is writing a credential into Vault and is a human call.
Worth fixing in the migration itself
337 guards on pg_cron being available but not on its secrets existing. A RAISE NOTICE ... RETURN when either secret is missing would have made this environment self-documenting instead of a footgun. Same class of issue as #559: a migration that "succeeds" while doing something useless.
Fixed on dev, 2026-09-17. It had got worse than the issue described: 337 had been applied to dev after all (ledger has it, six notifications-% jobs exist) with Vault still empty, so notifications-send-worker was failing every minute — 1,440 failures in the 24 h before this, all null value in column "url" of relation "http_request_queue".
What was done, via the Management API query endpoint with the PAT in .env:
vault.create_secret('https://pmtdqrfpumqwkdhpgwcz.supabase.co/functions/v1', 'edge_functions_url', …) — same shape as prod's.
service_role_key: first set to the legacy service_role JWT from GET /v1/projects/{ref}/api-keys, which prod uses. The functions answered 401. Dev has moved to the new API-key format, so its function runtime holds the sb_secret_… key as SUPABASE_SERVICE_ROLE_KEY, and _shared/notifications/auth.ts compares the Bearer to that byte-for-byte. Swapped the Vault value to dev's default secret key (type: secret) with vault.update_secret.
Verified: the 12:33 UTC run of notifications-send-worker got 200 {"ok":true,"processed":0,"results":[]} from pg_net; notifications-check-receipts likewise. No further failed rows in cron.job_run_details after 12:32.
Two things worth knowing that came out of it:
Prod and dev now hold different key formats in Vault (prod: legacy JWT, dev: sb_secret_). Both are correct for their project, because the runtime env differs. When prod migrates to the new keys, its service_role_key Vault row has to be updated the same way or the cron silently 401s. That belongs in the key-rotation runbook.
The migration-hardening suggestion (RAISE NOTICE and return when either secret is missing) still stands and is not done here. 337 is applied everywhere now, so it would be a new numbered migration that re-creates the jobs behind a guard, or a guard inside the job command itself. Filing that separately rather than editing an applied migration.
Activity
ci(supabase): run the migration drift audit on migration PRs
test(scf-core): merge duplicate vi.mock registrations; ci: drift audi…
ci(supabase): name the known cause when the drift audit exits non-zero (
ci(supabase): the drift audit names dev's cause even when prod is the…
thinkclay commentedon Sep 17, 2026
Fixed on dev, 2026-09-17. It had got worse than the issue described: 337 had been applied to dev after all (ledger has it, six
notifications-%jobs exist) with Vault still empty, sonotifications-send-workerwas failing every minute — 1,440 failures in the 24 h before this, allnull value in column "url" of relation "http_request_queue".What was done, via the Management API query endpoint with the PAT in
.env:vault.create_secret('https://pmtdqrfpumqwkdhpgwcz.supabase.co/functions/v1', 'edge_functions_url', …)— same shape as prod's.service_role_key: first set to the legacyservice_roleJWT fromGET /v1/projects/{ref}/api-keys, which prod uses. The functions answered 401. Dev has moved to the new API-key format, so its function runtime holds thesb_secret_…key asSUPABASE_SERVICE_ROLE_KEY, and_shared/notifications/auth.tscompares the Bearer to that byte-for-byte. Swapped the Vault value to dev'sdefaultsecret key (type: secret) withvault.update_secret.notifications-send-workergot200 {"ok":true,"processed":0,"results":[]}frompg_net;notifications-check-receiptslikewise. No furtherfailedrows incron.job_run_detailsafter 12:32.Two things worth knowing that came out of it:
sb_secret_). Both are correct for their project, because the runtime env differs. When prod migrates to the new keys, itsservice_role_keyVault row has to be updated the same way or the cron silently 401s. That belongs in the key-rotation runbook.