feat(config): warn on unknown local.yaml keys#63
Merged
KMX415 merged 1 commit intoJun 1, 2026
Conversation
85d4266 to
8d27b6e
Compare
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.
8d27b6e to
db6ca4a
Compare
Owner
|
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. |
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.
Summary
The config loader silently dropped any unknown key in
local.yaml. Thedataclass merge (
_merge_dataclass:if not hasattr: continue) means atypo like
tx_powr_dbminstead oftx_power_dbm, a stray nested key, or awhole misspelled section (
transmt:) just does nothing — with no signal tothe operator.
_apply_yamlnow collects every unapplied key (as dottedpaths, recursing only into nested dataclasses so user-populated maps like
meshtastic.channel_keysaren't false-flagged) and logs a single WARNINGlisting 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.yamlbut nothing happened" footgun. Amisspelled 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
Type
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_configintegration case. Behaviour is otherwiseunchanged — unknown keys are still ignored, known keys still merge as before.
Hardware:
Impact
Does this affect:
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?
If yes, how: Code written by author of commit and PR, reviewed and tested by Claude Code (Anthropic).