Skip to content

fix: restore appsettings.Development.json — a test loads it non-optionally - #592

Merged
mforce merged 1 commit into
mainfrom
fix/restore-dev-appsettings
Aug 24, 2026
Merged

mforce merged 1 commit into
mainfrom
fix/restore-dev-appsettings

Conversation

@mforce

@mforce mforce commented Aug 24, 2026

Copy link
Copy Markdown
Owner

Reverts #591. main is currently broken by it — three integration tests fail, and PR #588's CI surfaced it because PR runs test the branch merged into main.

What broke

tests/Cluckwork.Api.IntegrationTests/ProductionLogFormatTests.cs:318:

builder.AddJsonFile($"appsettings.{environment}.json", optional: false);

Non-optional. #591 untracked src/Cluckwork.Api/appsettings.Development.json (preserving its content as appsettings.Development.example.json), so the file is absent from a clean checkout and the three environment: "Development" cases throw:

System.IO.FileNotFoundException : The configuration file
'appsettings.Development.json' was not found and is not optional.

Failing: Non_production_configurations_bind_a_template_renderer(Development), Development_keeps_the_human_template_and_no_formatter, Exactly_one_console_sink_is_configured(Development). 1418 passed, 3 failed.

Why the revert rather than a fix-forward

Making the test's load optional, or repointing it at the .example.json, would keep CI green while deleting the guarantee. Those tests exist for #404: they assert the shipped Development config binds a template renderer and exactly one console sink — a formatter left beside a template is silently bound instead of it, which is the defect #404 records. If the file is not in the repo, there is no shipped Development config to assert about, and #404's Development-side guarantee becomes unverifiable.

So the file is load-bearing as a tracked artifact, not merely as content. #591 was wrong.

How I got it wrong

I claimed "nothing referenced the tracked file" after grepping Cluckwork.Api.csproj, Dockerfile, .github/, deploy/, tools/, and *.md + docs/. I never grepped tests/. A directory-filtered enumeration reported complete — the exact failure mode AGENTS.md #394 describes for contract changes ("list the references repo-wide, with no file-type filter"), applied to a file removal instead of a rename.

Verified after reverting: dotnet test --filter ProductionLogFormatTests → 15 passed, 0 failed.

The original concern still stands, and needs the other fix

#591 existed because a local Postgres connection string had been edited into that tracked file, one git commit -a from being committed to a GitGuardian-scanned repo. Untracking was the wrong remedy. The right one is the one AGENTS.md already prescribes, and UserSecretsId is already configured for it:

dotnet user-secrets --project src/Cluckwork.Api set "ConnectionStrings:Default" "..."

There is now hard evidence for why that is the only option: the file cannot be untracked without breaking a guard.

@mforce
mforce merged commit e10711c into main Aug 24, 2026
9 checks passed
@mforce
mforce deleted the fix/restore-dev-appsettings branch August 24, 2026 06:02
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.

2 participants