From 030cdc634f854526fe127f3d6d98121c52629fbf Mon Sep 17 00:00:00 2001 From: dingo Date: Sun, 12 Apr 2026 22:22:27 -0400 Subject: [PATCH] Fix NATS registration: register BazaarDbContext in AddAiService MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit AiDeckResolver depends on BazaarDbContext to look up prebuilt decks, but AddAiService never registered it. When NatsMessageRpcResponder.StartAsync called GetServices(), DI failed to instantiate GameAddAiHandler (via AiDeckResolver → BazaarDbContext not found), causing the entire NATS subscription startup to throw — leaving the AI pod with no NATS listeners. Fix: AddBazaarDatabase(configuration) is now called at the top of AddAiService before any handlers are registered. Generated with [Claude Code](https://claude.ai/code) via [Happy](https://happy.engineering) Co-Authored-By: Claude Co-Authored-By: Happy --- Server/src/SOR.Ai/ServiceRegistration.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Server/src/SOR.Ai/ServiceRegistration.cs b/Server/src/SOR.Ai/ServiceRegistration.cs index 8e8da38..b2166db 100644 --- a/Server/src/SOR.Ai/ServiceRegistration.cs +++ b/Server/src/SOR.Ai/ServiceRegistration.cs @@ -13,6 +13,7 @@ using SOR.Ai.Seeding; using SOR.Ai.Training; using SOR.Networking.Abstractions.Messaging; using SOR.Shared; +using SOR.Database; using SOR.Database.Contexts; /// @@ -26,6 +27,12 @@ public static class ServiceRegistration this IServiceCollection services, IConfiguration configuration) { + // ── Database contexts required by AI services ───────────────────────── + // AiDeckResolver needs BazaarDbContext to look up prebuilt decks. + // Safe to call even when AddBazaarService is also registered on the same host — + // EF Core resolves the last AddDbContext registration, and both point to the same DB. + services.AddBazaarDatabase(configuration); + // ── Startup seed (one-shot IHostedService) ──────────────────────────── // Ensures AI accounts exist in the DB before traffic is accepted. services.AddHostedService();