Skip to content

fix: accept Key/Keys in chapter descriptions and verify real content in CI - #1561

Open
BenjaminMichaelis wants to merge 2 commits into
mainfrom
fix/chapter-descriptions-schema-and-content-checks
Open

BenjaminMichaelis wants to merge 2 commits into
mainfrom
fix/chapter-descriptions-schema-and-content-checks

Conversation

@BenjaminMichaelis

Copy link
Copy Markdown
Member

Why

dev.essentialcsharp.com returns 500 on pages. ChapterDescriptionService throws while loading Chapters/sitemap.descriptions.json: the content package writes {"Key": "..."} per entry, but the shared SiteMappingDescription (19570, used since #1560) requires Keys. Deserializing the real 19570 file into that type throws ArgumentNullException ('keys'), so #1560 alone would not recover dev.

CI never caught it: tests build with AccessToNugetFeed=false (placeholders, which had no descriptions file), the only description test used a hand-written Keys fixture, the image built with real content is never run, and dev deploy had no smoke test. /health stays green because the service is built lazily on first page request.

What changed

  • ChapterDescriptionService accepts both Key and Keys; malformed entries throw an InvalidDataException naming the file and entry index.
  • Program.cs resolves ChapterDescriptionService and IGuidelinesService at startup so bad content fails the new revision rather than the first page request.
  • Placeholder sitemap.descriptions.json in the package's shape, copied by the csproj, so PR CI exercises the real code path.
  • ContentPackageContractTests (structural assertions only, no content in logs); chapter metadata tests no longer hard-code placeholder wording.
  • build-and-test now restores/builds with AccessToNugetFeed=true. Feed credentials are written only for the restore and removed before any repo code builds or runs. The job still runs only on push/workflow_dispatch, never for fork PRs.
  • scripts/smoke-test.sh requests /health, /, /hello-world, /guidelines; it now runs after the dev deploy and replaces the /health-only check in the prod deploy (prod already needs dev to succeed).

Test plan

  • dotnet test on placeholders: 199 passed
  • dotnet test --no-build with the real 19570 content package files in Chapters/ and Guidelines/: 199 passed
  • Workflow changes not run yet (YAML and script syntax checked only); the restore with user-level NuGet credentials is the part to watch on the first push to main

Follow-up (tooling repo)

Tooling should emit Keys (or change its type) so the shared SiteMappingDescription is actually used; until then the Key fallback keeps the site up.

…in CI

The 19570 content package writes sitemap.descriptions.json entries with a
singular "Key" while the shared SiteMappingDescription type requires "Keys",
so ChapterDescriptionService throws and every page 500s (dev outage).

- ChapterDescriptionService reads both shapes and reports malformed entries
  with the file and entry index.
- Resolve ChapterDescriptionService and IGuidelinesService at startup so bad
  content fails the new revision instead of the first page request.
- Add a placeholder sitemap.descriptions.json in the package's shape so PR CI
  exercises the real code path; make chapter metadata tests content-agnostic.
- Add ContentPackageContractTests (structural assertions only).
- build-and-test restores/builds against the real content package; feed
  credentials exist only during restore.
- Add scripts/smoke-test.sh (health + real pages) and run it after the dev
  deploy and in the prod deploy.
…hape

PlaceholderShapeTests compares property names and value kinds of
Placeholders/{sitemap,sitemap.descriptions,guidelines}.json against the
content files the build uses. It passes trivially on PR builds (content is
the placeholders) and runs for real in build-and-test on main, where the
content package is restored. Failures report only property names/kinds.

The check immediately found drift: the placeholder sitemap.json lacked
PrimaryKey and LastModified, which the package has. Add them.
BenjaminMichaelis added a commit that referenced this pull request Oct 24, 2026
## Summary
- Bumps `ToolingPackagesVersion` 1.1.1.19570 -> 1.1.1.19573.
- 19570's content package shipped `sitemap.descriptions.json` with the
old single-string `"Key"` format, which `SiteMappingDescription` (used
by `ChapterDescriptionService` since #1560) cannot deserialize, so dev
returned 500. 19573 is built from
IntelliTect-dev/EssentialCSharp.Tooling#2606, which converts the file to
the `Keys` array format and adds a tooling test that reads the real
file.

## Test plan
- [x] `dotnet build EssentialCSharp.Web.slnx`
- [x] `EssentialCSharp.Web.Tests`: 190 passed
- [x] At the tooling commit 19573 was built from (1f77290e),
`sitemap.descriptions.json` has 589 `"Keys"` entries and no `"Key"`
entries
- [ ] Not checked locally: the restored ContentFeedNuget package
contents. Please confirm dev serves pages after deploy.

Related: #1561 (Key/Keys compatibility and CI check against the real
package content) is still open and no longer needed to fix dev once this
is deployed.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant