Fix(OTP Login): fresh-install 500s; load settings from documents table - #1076
Merged
Conversation
Migration 0005_otp_codes.sql was added but the migrations bundle (migrations-bundle.ts) — the actual source MigrationService reads, not the .sql files — was not regenerated. On a fresh install 0005 never applied: otp_codes was never created and /auth/otp/request 500'd for a real user with `no such table: otp_codes`, and migrations.test.ts failed CI (bundle stopped at 0004 while the test expects 0005). Regenerate the bundle to include 0005, and retag the OTP regression spec @smoke so CI actually selects it (the migrations/otp change never triggers the @auth-only selection). Also correct the stale spec docstring (settings now come from the documents table, not `plugins`). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
loadOtpSettings hand-rolled raw SQL against the documents table and a dead fallback to the dropped legacy `plugins` table (R4 duplication). PluginService.getPlugin already reads the same plugin document (type_id='plugin', slug='otp-login') and returns its settings. Reuse it and drop the dead legacy path. Behavior unchanged: never throws, missing document or unparseable settings resolves to DEFAULT_SETTINGS. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
# Conflicts: # packages/core/src/db/migrations-bundle.ts
lane711
added a commit
that referenced
this pull request
Sep 4, 2026
Resolve migration-inventory conflicts with main's PR #1076 (OTP login plugin, migration 0005_otp_codes.sql): - migrations.test.ts: union both inventories — 0005 (otp_codes) from main plus 0006 (two_factor_lockout) / 0007 (two_factor_required) from this branch. Renumber the applied_at fixtures sequentially and bump appliedMigrations to 7. Drop the stale comment claiming 0005 was reserved for the FTS5 search PR. - migrations-bundle.ts: regenerated via `npm run generate:migrations` (R9); the my-sonicjs-app/migrations/ copies are byte-identical to packages/core/migrations/. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Same-repo mirror of #1056 (by @LukeSeers) so CI/CD runs without the fork authorize gate.
Summary
Fixes OTP login 500s on fresh installs. The legacy
plugins/otp_codestables were dropped when plugin settings moved todocuments(#858), but the OTP plugin still read fromplugins→ every/auth/otp/*request 500'd (no such table: plugins), and code storage neededotp_codes.documentstable viaPluginService.getPlugin('otp-login').otp_codestable (migration0005_otp_codes.sql) required byOTPService.migrations-bundle.ts(the actual sourceMigrationServicereads) → 5 migrations. This was missing from Fix(OTP Login): on fresh installs and load settings from the documents table #1056, so0005never applied andmigrations.test.tswould have failed CI.@smoke @authso CI selects it.Attribution
Maintainer changes
1b8b6dd02regenerate migrations bundle for 0005 + retag OTP e2e@smoke+ fix stale docstring2af7ec4ceload settings viaPluginService.getPlugin(drop hand-rolled document SQL + dead legacypluginsfallback)mainVerification
migrations.test.tsgreen🤖 Generated with Claude Code