Repository navigation
fix(config): reject misplaced known YAML keys instead of silently dropping them - #563
Open
almeidapaulopt wants to merge 1 commit into
Open
almeidapaulopt wants to merge 1 commit into
almeidapaulopt wants to merge 1 commit into
Conversation
…pping them The key normalizer looked keys up in a flat, schema-wide canonical map. A key that exists anywhere in the schema but not at the location used (e.g. `dashboard:` at the root — only valid inside preset templates — or `proxyAccessLog` under `log:` — a top-level field) passed the flat lookup, failed fieldTypeByCanonical, and was silently dropped. v2.3.4 rejected these via yaml KnownFields(true); the normalizer regressed that guarantee: configs booted with the misplaced settings silently ignored (worse than failing: adminAllowLocalhost could appear enabled while actually doing nothing). processStructField now reports such keys as unknown-field issues at their line/column, with suggestions scoped to the struct expected at that location — same treatment as truly unknown keys. Reported with repro in #562.
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.
What
Fixes #562.
processStructField(internal/config/keynormalizer.go) looked keys up in a flat, schema-wide canonical map. A key that exists anywhere in the schema but not at the location used — e.g.dashboard:at the root (only valid inside preset templates) orproxyAccessLogunderlog:(a top-level field) — passed the flat lookup, failedfieldTypeByCanonical, and hit a barereturn: silently dropped. The final plainyaml.Unmarshaldecode ignored the surviving key too.v2.3.4 rejected these configs at startup (
yaml KnownFields(true)); main regressed that guarantee. Silent no-ops are worse than boot failures:adminAllowLocalhost: truecan appear enabled while doing nothing.Change
Misplaced keys are now reported as unknown-field issues at their line/column, with suggestions scoped to the struct expected at that location — identical treatment to truly unknown keys:
Verification (TDD)
TestNormalize_RejectsMisplacedKnownKeysadded — misplaceddashboard:at root andproxyAccessLogunderlog:asserted to be rejected. Failed pre-fix (got nil error), including the subtest proving correct top-level placement decodes all values.keynormalizersuite (normalization, fuzzy suggestions, map-scope unknowns, line/column reporting) untouched and green.go test ./...— 25 packages ok, 0 failures.golangci-lintv2.15.0: 0 issues.Compatibility
clientId/client_id/CLIENTID): unchanged.files→listsalias (not yet on main; when it lands it rewrites the key before this check).