From 1ac14a5fee242d6c6f18fde4f7f9ed77759739af Mon Sep 17 00:00:00 2001 From: Benjamin Michaelis Date: Thu, 26 Nov 2026 14:06:03 -0800 Subject: [PATCH] fix: construct content-backed services at startup ChapterDescriptionService and IGuidelinesService are singletons built lazily on the first page request, so an unreadable content file left /health green while pages returned 500. Resolve them at startup so a bad content package fails the new revision before it takes traffic. --- EssentialCSharp.Web/Program.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/EssentialCSharp.Web/Program.cs b/EssentialCSharp.Web/Program.cs index 4fffe529..fac9c3a2 100644 --- a/EssentialCSharp.Web/Program.cs +++ b/EssentialCSharp.Web/Program.cs @@ -532,6 +532,11 @@ await McpJsonRpcResponseWriter.WriteErrorAsync( app.MapFallbackToController("Index", "Home"); + // Construct content-backed singletons now so an unreadable content file fails startup (the new + // revision never takes traffic) instead of surfacing as a 500 on the first page request. + app.Services.GetRequiredService(); + app.Services.GetRequiredService(); + // Validate sitemap data at startup — logs errors but allows startup to continue var siteMappingService = app.Services.GetRequiredService(); var logger = app.Services.GetRequiredService>();