Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(integration): log a failed boot scope reconcile neutrally
Yudhi Armyndharis76b9d60340eb
diff --git a/src/modules/integration/scope-binding.service.spec.ts b/src/modules/integration/scope-binding.service.spec.tsindex 0a1b61d7e..558726af2 100644--- a/src/modules/integration/scope-binding.service.spec.ts+++ b/src/modules/integration/scope-binding.service.spec.ts@@ -161,6 +161,24 @@ describe('ScopeBindingService.onApplicationBootstrap reconciliation', () => {).resolves.toBeUndefined();});+ it('logs a failure after the listing without blaming the listing', async () => {+ const { loader, audit, sessions } = build();+ const instances = {+ listAll: jest+ .fn()+ .mockResolvedValue([+ { pluginId: 'chatwoot', instanceId: 'a', sessionScope: 'sess-1', config: {}, enabled: true },+ ]),+ } as unknown as PluginInstanceService;+ const svc = new ScopeBindingService(instances, loader, audit, sessions);+ jest.spyOn(svc, 'applyScopeBinding').mockRejectedValue(new Error('bind failed'));+ const error = jest.spyOn((svc as unknown as { logger: { error: jest.Mock } }).logger, 'error');+ error.mockImplementation(() => undefined);++ await expect(svc.onApplicationBootstrap()).resolves.toBeUndefined();+ expect(error).toHaveBeenCalledWith('Scope-binding reconciliation failed', 'Error: bind failed');+ });+// A scope pointing at a deleted session binds the plugin to nothing, and every other signal an// operator can read (instance `enabled`, plugin `status`, healthCheck) stays green — so the log line// is the only place the inertness can surface.diff --git a/src/modules/integration/scope-binding.service.ts b/src/modules/integration/scope-binding.service.tsindex e2abac33f..d7f14a183 100644--- a/src/modules/integration/scope-binding.service.ts+++ b/src/modules/integration/scope-binding.service.ts@@ -44,7 +44,7 @@ export class ScopeBindingService implements OnApplicationBootstrap {try {await this.reconcile();} catch (err) {- this.logger.error('Scope-binding reconciliation skipped (failed to list instances)', String(err));+ this.logger.error('Scope-binding reconciliation failed', String(err));}}