fix(discord): honor documented env-wins-over-config precedence for require_mention/free_response_channels - #13732
Closed
hclsys wants to merge 1 commit into
Closed
Conversation
…quire_mention/free_response_channels (NousResearch#13685) The docs for the discord channel state: Config.yaml settings are applied as defaults — if the equivalent env var is already set, the env var wins. But the _discord_require_mention and _discord_free_response_channels helpers checked config.extra first and only fell back to the env var when config was unset. That inverts the documented contract for the two most commonly configured Discord gating fields. Swap the order so the env var is read first (and actively-set values win over config.yaml), and fall back to config.extra when env is unset. Treat an empty-string env value as 'not actively set' so unset-vs-empty remains distinguishable and a fresh install's config.yaml still works. Add 6 regression tests covering: - env TRUE overrides config FALSE (and vice versa) for require_mention - config value used when env unset - default TRUE when neither set - env list overrides config list for free_response_channels - empty env string falls through to config (unset-vs-empty guard)
Author
|
Closing — not pursuing further. Thanks for the triage. |
19 tasks
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
Fixes #13685. The Discord channel docs state:
But `_discord_require_mention` and `_discord_free_response_channels` in `gateway/platforms/discord.py` checked `config.extra` first and only fell back to the env var when config was unset — inverting the documented contract for the two most commonly configured Discord gating fields. Since `require_mention: true` is the default in a fresh `config.yaml`, the env var never wins in practice.
Fix
Swap the order in both helpers: env var read first, config.extra as fallback, hardcoded default last. An empty-string env value is treated as not actively set so unset-vs-empty remains distinguishable (an empty string does not mask a non-empty config list).
Test
Added 6 regression tests in `TestDiscordEnvPrecedenceOverConfig`:
All 6 new tests pass locally. Pre-existing async tests in the same file fail due to missing `pytest-asyncio` in the local venv — unrelated to this change (same 20 failures present on `main` without my patch).
Scope
2 private methods in 1 adapter. Pure precedence swap — no new capability. Rule out: I checked `PR #9837` which touches `reply_to_mode` (different field), not a rival for these two fields.
Closes #13685.