The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.
TypeScript budget-trackercollaborativedockeritinerarymcp-serveroffline-firstopen-sourceopenstreetmappacking-listpwareal-timeself-hostedselfhostedtraveltravel-apptravel-journaltravel-plannertripitwanderlog
fix(plugins): mark a plugin that waits for re-consent as failed at boot
Maurice7fe4fbb68310
diff --git a/server/scripts/size-baseline.json b/server/scripts/size-baseline.jsonindex 910684897..f41522dc7 100644--- a/server/scripts/size-baseline.json+++ b/server/scripts/size-baseline.json@@ -13,7 +13,7 @@"src/nest/doc-sync/providers/synology-drive.client.ts": 1160,"src/nest/journey/journey-domain.service.ts": 1659,"src/nest/places/places.service.ts": 1546,- "src/nest/plugins/plugin-runtime.service.ts": 1459,+ "src/nest/plugins/plugin-runtime.service.ts": 1458,"src/nest/plugins/runtime/plugin-sdk.ts": 1093,"src/nest/reservations/reservations.service.ts": 1163,"src/nest/vacay/vacay.service.ts": 1393diff --git a/server/src/nest/plugins/plugin-runtime.service.ts b/server/src/nest/plugins/plugin-runtime.service.tsindex a93a1824e..4c3c31ae4 100644--- a/server/src/nest/plugins/plugin-runtime.service.ts+++ b/server/src/nest/plugins/plugin-runtime.service.ts@@ -386,31 +386,25 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDes// own gate still refuses to spawn, so nothing boots into a broken state.order = enabledIds;}- // task-6-rereview.md I1: assertActivatable (inside activate) reads- // AddonsService.isAddonEnabled — repository-backed — so this boot loop needs- // the same request-context wrap every other D6 choke point got, or an- // enabled plugin with a non-empty requiredAddons throws cannotUseGlobalContext- // here, silently: the .catch below only reconciles PluginDependencyError /- // DependencyCycleError, and the outer try/catch around this whole block eats- // everything else.- // `activate()` itself stays unwrapped (its HTTP callers already run inside a- // request); only this boot-time call site needs it. Fail closed the same way- // the boot RULING (task-6-rereview.md §2) settled for CronRegistrarService.- // runOnBoot: no ORM means skip loudly and never call activate — never abort- // app.init() over a partially-wired test graph.+ // activate() reads repositories, so this boot-time call site opens its own request+ // context (its HTTP callers already run inside one). No ORM means skip loudly and+ // never call activate, never abort app.init() over a partially-wired test graph.if (!this.orm) {// Plan 3j Task 2: `order`/`enabledIds` are always empty here now (see the// `installed = new Map()` note above) — the message can no longer name// specific plugins, only that boot skipped activation entirely.logError('PluginRuntimeService.onApplicationBootstrap: no MikroORM available — plugin activation skipped');} else {+ const orm = this.orm;for (const id of order) {- withRequestContext(this.orm, () => this.activate(id)).catch((e) => {+ withRequestContext(orm, () => this.activate(id)).catch((e) => {// A plugin whose required addon is off (or a dependency is missing) at boot// must not stay marked enabled — reconcile the row so the UI reflects reality.if (e instanceof PluginDependencyError || e instanceof DependencyCycleError) {this.deactivate(id).catch(() => {});}+ // A refused re-consent never reaches the supervisor hook, which leaves last run's 'active' row.+ if (e instanceof PluginConsentRequired) void this.markBootRefused(orm, id, e.message);/* other failures: status is persisted as error by the supervisor hook */});}@@ -820,6 +814,11 @@ export class PluginRuntimeService implements OnApplicationBootstrap, OnModuleDesreturn true;}+ /** @txStandalone a status note on one plugin row that stands whatever the boot loop does. */+ private async markBootRefused(orm: MikroORM, id: string, message: string): Promise<void> {+ await withRequestContext(orm, () => this.plugins.updateStatusAndError(id, 'error', message)).catch(() => {});+ }+async deactivate(id: string): Promise<void> {await this.supervisor.disable(id);closePluginDataDb(id);diff --git a/server/tests/integration/plugins/plugin-runtime.task2-conversion.test.ts b/server/tests/integration/plugins/plugin-runtime.task2-conversion.test.tsindex c1b562773..756831470 100644--- a/server/tests/integration/plugins/plugin-runtime.task2-conversion.test.ts+++ b/server/tests/integration/plugins/plugin-runtime.task2-conversion.test.ts@@ -573,3 +573,38 @@ describe('Plan 3j Task 2 — two racing ticks (scheduler claim/re-arm + erasure}});});++describe('onApplicationBootstrap: a plugin that cannot start keeps no stale active row', () => {+ async function bootAndSettle(id: string, status: string) {+ const rt = await buildRuntime();+ await rt.onApplicationBootstrap();+ await vi.waitFor(async () => expect((await pluginRow(id)).status).toBe(status), { timeout: 1000, interval: 25 });+ await rt.onModuleDestroy();+ }++ it('BOOT-STATUS-001: new permissions awaiting consent leave the row in error with the reason', async () => {+ const id = 'boot-widened';+ // active from the last run; the stored manifest now declares db:read:users on top of the grant+ await seedPlugin(id, { enabled: 1, permissions: '["db:own","db:read:users"]', granted_permissions: '["db:own"]' });+ await updateRows(t, Plugins, { id }, { status: 'active' });++ await bootAndSettle(id, 'error');++ const row = await pluginRow(id);+ expect(row.status).toBe('error');+ expect(row.last_error).toBe(`plugin ${id} requests new permissions; explicit re-consent is required`);+ expect(row.enabled).toBe(1);+ });++ it('BOOT-STATUS-002: a dependency refusal still turns the plugin off instead of marking it error', async () => {+ const id = 'boot-api-too-new';+ await seedPlugin(id, { enabled: 1, api_version: 999 });+ await updateRows(t, Plugins, { id }, { status: 'active' });++ await bootAndSettle(id, 'inactive');++ const row = await pluginRow(id);+ expect(row.status).toBe('inactive');+ expect(row.enabled).toBe(0);+ });+});