Skip to content

notification cron jobs should refuse to run when their Vault secrets are missing, instead of enqueuing NULL-url requests every minute #805

Open

Description

@thinkclay

Follow-up to #564, where dev ran notifications-send-worker 1,440 times a day into null value in column "url" of relation "http_request_queue" because migration 337's jobs read edge_functions_url and service_role_key from Vault at execution time and nothing checks they exist.

Evidence

packages/supabase/migrations/337_notification_cron_vault.sql schedules six pg_cron jobs whose command is roughly:

select net.http_post(
  url := (select decrypted_secret from vault.decrypted_secrets where name = 'edge_functions_url' limit 1) || '/notify-send-worker',
  headers := jsonb_build_object('Authorization', 'Bearer ' || (select decrypted_secret from vault.decrypted_secrets where name = 'service_role_key' limit 1), ...),
  ...)

With either row absent the subselect is NULL, url is NULL, and pg_net rejects the insert — one failed row per schedule tick, forever, and nothing surfaces it. The migration guards on pg_cron being installed but not on the secrets it depends on.

A second trap found on #564: the service_role_key value must match what the function runtime holds as SUPABASE_SERVICE_ROLE_KEY, which is the legacy JWT on prod and the new sb_secret_… key on dev. A wrong-but-present key fails as a 401 from the function, visible only in net._http_response.

Acceptance

  • A new numbered migration (337 is applied on every environment; do not edit it) wraps the six job commands in a guard: when either Vault row is missing, RAISE WARNING once and return without calling net.http_post. A small notifications.cron_target() helper returning (url, bearer) or NULL keeps the six commands identical.
  • The guard is exercised locally: with the two rows deleted from Vault on a local stack, a manual cron.job run produces no http_request_queue row and one warning.
  • docs/agents/RELEASE-PROCESS.md (or the runbook that covers key rotation) says: when a project moves to the new API keys, update its service_role_key Vault row to the sb_secret_ value, then confirm net._http_response shows 200 for the next notifications-send-worker tick.

Related: #564, #559 (same class: a migration that "succeeds" while doing something useless).

Activity

  1. added
    agent-ready
    on Sep 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Backendagent-ready

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions