Skip to content

fix(config): report invalid mixed file-root properties #817

Closed as not planned

Description

@akrock

Context

A configuration file with one invalid root property and one valid sibling currently uses the valid sibling without telling an auditor that another property was ignored. Operators need complete evidence; runtime startup should still follow normal required-config rules. This addresses a remaining review concern on PR #813.

Current State

Verified 2026-09-23. ConfigFileTokenProjection.Parse throws for an invalid root only when no representable entries remain (Config/ForgeTrust.AppSurface.Config/ConfigFileTokenProjection.cs:84-91). ReadObject notices invalid root names but does not return a diagnostic for mixed files (same file:102-115). FileBasedConfigProvider.GetReportDiagnostics already supports file-level diagnostics with null key/path (Config/ForgeTrust.AppSurface.Config/FileBasedConfigProvider.cs:238-244). The manager resolves values synchronously; required wrapper validation occurs after resolution (Config/ForgeTrust.AppSurface.Config/DefaultConfigManager.cs:40-112, Config/ForgeTrust.AppSurface.Config/Config.cs:63-72).

Proposed Change

Keep valid sibling values, layering, and provenance. When any root property cannot be represented as a logical key but at least one valid sibling exists, publish one file-level Error diagnostic per affected source file, with stable code config-file-invalid-root-property, null key/path, safe file identity, and a value-free message that properties were ignored. Do not promote it to a blanket runtime terminal result. A required config value fails startup only when normal resolution leaves it absent or invalid; optional config can remain missing. Preserve the current all-invalid/malformed-file behavior as a separate control case. Document the distinction in the file provider and audit guides.

Acceptance Criteria

  1. A mixed file emits exactly one file-level config-file-invalid-root-property Error, with no raw value or invalid property content in diagnostic prose.
  2. Its valid sibling resolves with the same value and source provenance as before; an invalid root never appears as an empty layer or valid key.
  3. An optional missing key does not fail startup; an unresolved [ConfigKeyRequired] key fails through the existing required-config validation path.
  4. All-invalid and well-formed files retain their existing controls; formatting, relevant tests, and changed-branch verification pass without new warnings.

Testing Plan

Layer Cases
Projection/provider Mixed root, multiple invalid roots in one file, all-invalid control, provenance of valid sibling
Public report File-level Error appears once and contains no secret value
Config wrapper Optional missing continues; required missing fails normally

Rollback Plan

Revert the projection/provider diagnostic change; no persisted data format changes.

Effort Estimate

Projection and diagnostic: ~0.25 day; public regressions and docs: ~0.5 day. Total ~0.5-1 day.

Files Reference

File Change
Config/ForgeTrust.AppSurface.Config/ConfigFileTokenProjection.cs:84 Carry mixed-root invalidity to snapshot creation
Config/ForgeTrust.AppSurface.Config/FileBasedConfigProvider.cs:310 Publish file-level Error
Config/ForgeTrust.AppSurface.Config.Tests/FileProjectionContractTests.cs:62 Mixed/all-invalid controls

Out of Scope

Rejecting the entire mixed file, changing provider priority, changing required-config semantics, or echoing invalid property values.

Related

PR #813: #813

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions