fix(ungated-global): create settings secret with a valid backend FK #138

Merged
michal merged 1 commits from fix/ungated-global-secret-fk into main 2026-10-03 00:58:58 +00:00
Owner

Follow-up to #137. On a DB where the mcpctl-system-settings secret didn't exist, bootstrapUngatedGlobal's markSeeded created it with the default backendId: '', violating Secret_backendId_fkey at insert time → mcpd crash-looped on startup (P2003). Caught in deploy (mcpd rolled back to restore service).

Fix:

  • Run bootstrapUngatedGlobal after bootstrapSecretBackends so the default plaintext backend exists.
  • Resolve the default backend (by name, else isDefault, else any) and set backendId on create; if no backend exists at all, skip writing the marker rather than crash.

Test updated to assert the valid backendId on the create path.

🤖 Generated with Claude Code

Follow-up to #137. On a DB where the `mcpctl-system-settings` secret didn't exist, `bootstrapUngatedGlobal`'s `markSeeded` created it with the default `backendId: ''`, violating `Secret_backendId_fkey` at insert time → mcpd crash-looped on startup (P2003). Caught in deploy (mcpd rolled back to restore service). Fix: - Run `bootstrapUngatedGlobal` **after** `bootstrapSecretBackends` so the default plaintext backend exists. - Resolve the default backend (by name, else `isDefault`, else any) and set `backendId` on create; if no backend exists at all, skip writing the marker rather than crash. Test updated to assert the valid `backendId` on the create path. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
michal added 1 commit 2026-10-03 00:58:52 +00:00
fix(ungated-global): create settings secret with a valid backend FK
Some checks failed
CI/CD / typecheck (pull_request) Successful in 1m19s
CI/CD / test (pull_request) Failing after 27s
CI/CD / lint (pull_request) Successful in 2m50s
CI/CD / smoke (pull_request) Has been skipped
CI/CD / build (pull_request) Has been skipped
CI/CD / publish (pull_request) Has been skipped
fe00f42bce
bootstrapUngatedGlobal wrote its seed marker into the mcpctl-system-settings
Secret, creating the row with the default backendId '' when it did not exist.
The Secret_backendId_fkey constraint is enforced at insert time, so on a DB
where that secret was absent, mcpd crash-looped on startup (P2003).

Fix: run the seed after bootstrapSecretBackends (so the default plaintext
backend exists) and set backendId to the resolved default on create. If no
backend exists at all, skip writing the marker rather than crash.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
michal merged commit 5415060de6 into main 2026-10-03 00:58:58 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: michal/mcpctl#138