Skip to content

feat(config): warn on unknown local.yaml keys#63

Merged
KMX415 merged 1 commit into
KMX415:feat/v0.7.6from
ryannzander:feat/config-unknown-key-warning
Jun 1, 2026
Merged

feat(config): warn on unknown local.yaml keys#63
KMX415 merged 1 commit into
KMX415:feat/v0.7.6from
ryannzander:feat/config-unknown-key-warning

Conversation

@ryannzander
Copy link
Copy Markdown
Contributor

Summary

The config loader silently dropped any unknown key in local.yaml. The
dataclass merge (_merge_dataclass: if not hasattr: continue) means a
typo like tx_powr_dbm instead of tx_power_dbm, a stray nested key, or a
whole misspelled section (transmt:) just does nothing — with no signal to
the operator. _apply_yaml now collects every unapplied key (as dotted
paths, recursing only into nested dataclasses so user-populated maps like
meshtastic.channel_keys aren't false-flagged) and logs a single WARNING
listing them plus the file path. A non-mapping top-level YAML is now warned
and skipped instead of relying on incidental no-crash behaviour.

Adds tests/test_config_loader.py — first direct coverage of the loader.

Why

Recurring "I set it in local.yaml but nothing happened" footgun. A
misspelled field gives zero feedback today, so operators burn time
debugging a setting that was never applied. Surfacing it as one log line
turns a silent failure into an obvious one. This is a pure config-validation

  • logging change, which CONTRIBUTING lists as a safe area to contribute.

Type

  • Bug fix
  • Feature
  • Docs
  • Refactor
  • UI
  • Installer
  • Region support
  • Hardware change

Testing

python -m pytest tests/test_config_loader.py tests/test_radio_frequency_resolver.py
→ 24 passed. ruff check src/config.py tests/test_config_loader.py → clean.
New tests cover: flat/nested unknown keys, dotted nested paths, the
mapping-field exemption, an unknown top-level section, the non-mapping
guard, and a load_config integration case. Behaviour is otherwise
unchanged — unknown keys are still ignored, known keys still merge as before.

  • Local only
  • Tested on hardware
  • Dashboard tested
  • Docs only
  • UI only

Hardware:

  • Pi: n/a (config-layer change, no hardware exercised)
  • Concentrator: n/a
  • Node/radio: n/a
  • Region: n/a
  • OS: developed on Windows; logic is pure Python/stdlib + PyYAML, CI runs Python 3.12

Impact

Does this affect:

  • Parsing
  • Relay
  • TX
  • Radio driver
  • Region logic
  • UI only
  • Installer only

Notes: None of the above. Touches only src/config.py (YAML→dataclass merge)
and adds a test. No RF/radio/concentrator/region code changed; the only new
runtime behaviour is a WARNING log line. Known keys are applied exactly as
before.

AI-assisted?

  • No
  • Yes

If yes, how: Code written by author of commit and PR, reviewed and tested by Claude Code (Anthropic).

@ryannzander ryannzander force-pushed the feat/config-unknown-key-warning branch from 85d4266 to 8d27b6e Compare June 1, 2026 01:38
The config loader merges YAML onto dataclasses and silently drops any
key with no matching field (`_merge_dataclass`: `if not hasattr: continue`).
A typo like `tx_powr_dbm`, a stray nested key, or a whole misspelled
section (`transmt:`) just does nothing, with no signal to the operator --
a recurring "I set it in local.yaml but nothing happened" footgun.

`_apply_yaml` now collects unapplied keys (dotted paths, recursing only
into nested dataclasses so user maps like `meshtastic.channel_keys` are
not flagged) and logs a single WARNING listing them and the file path.
Behaviour is otherwise unchanged: unknown keys are still ignored, known
keys still merge as before. A non-mapping top-level YAML is now warned
and skipped instead of relying on incidental no-crash behaviour.

Adds tests/test_config_loader.py: first direct coverage of the loader
merge path, the unknown-key warning, dotted nested paths, mapping-field
exemption, unknown section, the non-mapping guard, and a load_config
integration case.

Tested: python -m pytest tests/test_config_loader.py
tests/test_radio_frequency_resolver.py (24 passed); ruff clean on both
files. Pure config-layer change, no hardware/radio impact.
@KMX415 KMX415 force-pushed the feat/config-unknown-key-warning branch from 8d27b6e to db6ca4a Compare June 1, 2026 02:27
@KMX415 KMX415 changed the base branch from main to feat/v0.7.6 June 1, 2026 02:27
@KMX415 KMX415 merged commit d41c4a0 into KMX415:feat/v0.7.6 Jun 1, 2026
1 check passed
@KMX415
Copy link
Copy Markdown
Owner

KMX415 commented Jun 1, 2026

Rebased onto \ eat/v0.7.6, CI green, merged. Ships with the v0.7.6 sprint (not a separate patch). Thanks for closing the silent-typo footgun.

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