Skip to content

config: misplaced known YAML keys are silently dropped on main (v2.3.4 rejected them) #562

Open

Description

@almeidapaulopt

Summary

On main (v3 line), a config key that exists somewhere in the schema but not at the location used is silently accepted and dropped. v2.3.4 rejected these configs at startup via yaml KnownFields(true).

Repro

dashboard:
  adminAllowLocalhost: true   # dashboard: only valid inside preset templates

log:
  level: info
  proxyAccessLog: true        # proxyAccessLog: is a top-level field
  • v2.3.4 (expected behavior): refuses to boot —
    line 22: field dashboard not found in type config.config
    line 28: field proxyAccessLog not found in type config.LogConfig
    
  • main: boots fine, both settings silently ignored. adminAllowLocalhost can appear enabled while actually doing nothing — arguably worse than a boot failure.

Root cause

processStructField (internal/config/keynormalizer.go) looks keys up in a flat, schema-wide canonical map (keyLookup.canonical). Misplaced keys pass the flat lookup, fail the path-aware fieldTypeByCanonical(typ, canonical), and hit a bare return:

fieldType, ok := lookup.fieldTypeByCanonical(typ, canonical)
if !ok {
    return  // ← misplaced known key silently dropped
}

The final root.Decode(out) is a plain yaml.Unmarshal (no KnownFields), so the surviving unknown key is ignored by decode too.

Impact

Real-world instance: our own getting-started docs shipped exactly this block (dashboard: section + proxyAccessLog under log:) — see #559 / PR #561. Any user migrating a v2 config by editing it runs into silent no-ops instead of errors.

Proposed fix

Report such keys as unknown-field issues (same shape as truly unknown keys: line/column + suggestions scoped to the struct expected at that location).

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

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions