Skip to content

fix(pm-dispatch): sops-managed Supabase config; SUPABASE_URL required (#5120) - #5129

Merged
developing-today[bot] merged 1 commit into
mainfrom
dispatch-supabase-sops
Nov 3, 2026
Merged

developing-today[bot] merged 1 commit into
mainfrom
dispatch-supabase-sops

Conversation

@developing-today

@developing-today developing-today Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Why

On 2026-11-03 pm-dispatch's queue writes failed fleet-wide: its Supabase config resolved to the legacy muse-dev project, which has been deleted (public DNS NXDOMAIN; Management API 404 "Resource has been removed"). Two layers pointed there:

  • pm-stack/dispatch/src/config.ts defaulted SUPABASE_URL to the legacy host whenever the env var was unset;
  • the service-role key lived in the hand-maintained ~/secrets/dispatch.env, placed there from Bitwarden's un-namespaced supabase.service-role-key — which is the legacy project's key.

The hot fix repointed the live env file at muse-dev2 (keihfchslgjetkmnmzra) and the service is healthy again, but the fix lived only in a hand-edited file. Per Drew's ruling ("NixOS should manage it"), this PR moves pm-dispatch's Supabase config into the pm-stack SOPS layer, rendered by install.sh like the stack's other secrets.

Refs #5120 — this PR fixes the pm-dispatch scope of that issue; the pm-stack/supabase-export legacy refs audited there are a separate remainder.

Changes

  • secrets/pm-stack.sops.yaml — add supabase_url + supabase_service_role_key (muse-dev2). The key's source of truth is Bitwarden supabase.muse-dev2.service-role-key; its JWT ref claim was verified against the project before the edit and again from the re-encrypted file after it, and all 20 pre-existing keys decrypt byte-identically after the edit.
  • pm-stack/dispatch/install.sh — render SUPABASE_URL + SUPABASE_SERVICE_ROLE_KEY into ~/pm-stack/dispatch/.env from the SOPS file, with the GitHub App material (same sops -d --extract pattern). The operator file is DISPATCH_API_TOKEN-only by design now; install.sh warns loudly if stale SUPABASE_* lines remain there (the unit reads that file after the rendered one, so leftovers would override the managed values). The header also documents the Bitwarden trap: the un-namespaced supabase.* secrets are the deleted legacy project's.
  • pm-stack/dispatch/src/config.ts — SUPABASE_URL is required; there is no default. loadConfig throws at startup when it is unset or blank. Fail-loud over defaulting to the muse-dev2 URL: a silent default is exactly what turned a deleted project into a fleet-wide outage, and the deployment always renders the value.
  • Tests — config.test.ts gains a fixture env plus SUPABASE_URL required / trailing-slash tests; the three server-importing suites pin a fixture URL before importing src/server.ts (the package's existing dynamic-import idiom), since config now loads at import time.
  • Docs/comments — NixOS pm-stack module, fallback unit (pm-stack/systemd/pm-dispatch.service), pm-stack/dispatch/README.md, pm-stack/README.md. The unit's EnvironmentFile wiring already pointed at the rendered path first; the module change is comments only.

No behavior change today

The running service reads ~/secrets/dispatch.env, which already carries the same muse-dev2 URL and key from the hot fix (identical key value — same Bitwarden source). Nothing in this PR restarts or reconfigures the live service.

Deploy (with the next switch / deploy round)

  1. Merge; the updated secrets/pm-stack.sops.yaml lands at ~/secrets/pm-stack.sops.yaml on the laptop by the usual flow.
  2. Run pm-stack/dispatch/install.sh (or let pm-git-sync's redeploy do it — the SOPS ciphertext is a hashed deploy input, so the change re-renders and restarts automatically).
  3. Delete the SUPABASE_URL / SUPABASE_SERVICE_ROLE_KEY lines from ~/secrets/dispatch.env (install.sh warns until this is done). DISPATCH_API_TOKEN stays in the operator file, as before.

Until that deploy runs, the interim state is the hot-fixed operator file: correct values, hand-maintained.

Verification (on the laptop)

  • bun test: 131 pass / 0 fail (origin/main baseline: 129 pass; +2 new tests). bunx tsc --noEmit: only the pre-existing test/queue.test.ts TS2352, byte-identical on origin/main.
  • bash -n install.sh clean. Extraction of both new keys from the updated SOPS file verified (URL value; key JWT ref = keihfchslgjetkmnmzra).
  • NixOS/home: home.activationPackage for host amd builds with these changes; the generated pm-dispatch.service in the built generation carries EnvironmentFile=/home/user/pm-stack/dispatch/.env then EnvironmentFile=-/home/user/secrets/dispatch.env, unchanged, and the eval of systemd.user.services.pm-dispatch.Service.EnvironmentFile returns exactly that pair.
  • The diff contains no plaintext secret material (SOPS ciphertext only).

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@developing-today
developing-today Bot requested review from a team and dezren39 as code owners November 3, 2026 20:38
@coderabbitai

coderabbitai Bot commented Nov 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: adf65b25-4c31-4676-ab5a-27e74d50a2bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

CodeRabbit Verify

  • Run CodeRabbit Verify to test the changes in this pull request.

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.

0 participants