Skip to content

feat: warn at startup on unrecognized mcbot.conf keys/sections - #24

Merged
sg merged 1 commit into
mainfrom
feat/warn-unknown-config-keys
Jun 16, 2026
Merged

feat: warn at startup on unrecognized mcbot.conf keys/sections#24
sg merged 1 commit into
mainfrom
feat/warn-unknown-config-keys

Conversation

@sg

@sg sg commented Jun 16, 2026

Copy link
Copy Markdown
Owner

Summary

mcbot.conf isn't strictly validated, so a typo'd or stale setting was silently ignored. The bot now logs each unrecognized section/key loudly at WARNING on startup:

[WARNING] mcbot.conf: [bot] unrecognized key 'foo' (ignored)
[WARNING] mcbot.conf: unrecognized section [bogus] (ignored)
[WARNING] mcbot.conf: [bot] 'rx_log_decrypt' is deprecated and ignored (safe to remove)

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 what load_config reads.
    • _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 into cfg.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 deprecated rx_log_decrypt are each flagged; [env]/[channels] keys are not.
  • Bot_Usage.md — documents the behavior.

Maintenance note

_KNOWN_CONFIG_KEYS must be updated when a new setting is added; it sits right above load_config with a reminder comment.

Testing

py_compile clean; new test passes; all five existing suites pass.

@sg
sg merged commit 414aeee into main Jun 16, 2026
1 check passed
@sg
sg deleted the feat/warn-unknown-config-keys branch June 16, 2026 16:38
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.

1 participant