feat: warn at startup on unrecognized mcbot.conf keys/sections - #24
Merged
Conversation
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
mcbot.confisn't strictly validated, so a typo'd or stale setting was silently ignored. The bot now logs each unrecognized section/key loudly atWARNINGon startup:It's non-fatal — the bot still starts (a typo shouldn't brick it).
Changes
mcbot.py:_KNOWN_CONFIG_KEYS— recognized keys per section, kept in sync with whatload_configreads._DYNAMIC_CONFIG_SECTIONS(env,channels) — arbitrary keys allowed, not checked (their keys are user data, not option names)._DEPRECATED_CONFIG_KEYS(bot.rx_log_decrypt) — reported as deprecated/“safe to remove” rather than a generic unknown key, so upgraders get a friendly nudge._check_unknown_config_keys(parser)collects warnings intocfg.config_warnings;run()logs them after the startup banner.tests/test_config_keys.py— valid config yields zero warnings (no false positives); unknown key, unknown section, and deprecatedrx_log_decryptare each flagged;[env]/[channels]keys are not.Bot_Usage.md— documents the behavior.Maintenance note
_KNOWN_CONFIG_KEYSmust be updated when a new setting is added; it sits right aboveload_configwith a reminder comment.Testing
py_compileclean; new test passes; all five existing suites pass.