Repository navigation
fix: construct content-backed services at startup - #1734
Open
BenjaminMichaelis wants to merge 1 commit into
Open
BenjaminMichaelis wants to merge 1 commit into
BenjaminMichaelis wants to merge 1 commit into
Conversation
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.
This was referenced Nov 26, 2026
BenjaminMichaelis
added a commit
that referenced
this pull request
Nov 28, 2026
## Why The dev outage came from `sitemap.descriptions.json` changing shape (`Key` vs `Keys`), and the placeholders that PR builds use did not model that file at all, so CI could not notice. ## What changed - Add `Placeholders/sitemap.descriptions.json` in the shape the content package now ships (`Keys` + `Value`, matching `SiteMappingDescription`) and copy it into `Chapters/` for placeholder builds. - Bring `Placeholders/sitemap.json` in line with `SiteMapping` (`PrimaryKey`, `LastModified`). - Add `PlaceholderShapeTests`, which compares each placeholder's JSON property names and value kinds with the content files the app loads. Built against the real content package (`-p:AccessToNugetFeed=true`) it fails when the package changes shape; failures print property names only, so no book content reaches a public log. ## Relation to earlier work This is the remaining part of #1561, which was closed in favour of #1734 (startup check). Not included: the `Key`/`Keys` reader fallback (tooling ships `Keys`), the smoke-test script (main runs the Playwright `Deployed` smoke tests), and a real-package restore in CI, which should be reviewed on its own. Until that exists, `PlaceholderShapeTests` compares the placeholders with themselves in CI. ## Test plan - [x] `EssentialCSharp.Web.Tests`: 351 passed; 2 failures (`CaptchaService_Verify_Success`, `KnownBreachedPassword_IsDetected`) call external services and are unrelated. - [x] `Parser.Shared.dll` from package 19663 declares `SiteMappingDescription { Keys, Value }` and `SiteMapping` with `PrimaryKey` and `LastModified`, matching the placeholders. - [ ] Not run against the real content files (no feed credentials available).
This branch has not been deployed
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.
Why
On dev, a bad
sitemap.descriptions.jsonmade every page return 500 while/healthstayed green, becauseChapterDescriptionService(andIGuidelinesService) are singletons built lazily on the first page request. The failure only appeared after the revision was already serving traffic.What changed
Program.csresolvesChapterDescriptionServiceandIGuidelinesServiceat startup, right after the routes are mapped. An unreadable content file now fails startup, so the new container revision never takes traffic.Relation to #1561
This is the startup-check part of #1561, rebased onto current
main. The rest of #1561 is intentionally not included:Key/Keyscompatibility code is no longer needed (tooling now shipsKeys, chore: bump tooling packages to 1.1.1.19573 #1562).mainnow runs the PlaywrightDeployedsmoke tests (including the reading journey) after the dev deploy, and prod promotion needs them.AccessToNugetFeed=trueCI changes carry more risk and should be reviewed on their own.Test plan
EssentialCSharp.Web.Tests: 350 passedEssentialCSharp.Web.AppHost(NETSDK1228, Aspire workload deprecated in this SDK); unrelated to this change. I built and tested the web and test projects directly.