sopel-irc / sopel

:robot::speech_balloon: An easy-to-use and highly extensible IRC Bot framework. Formerly Willie.
https://sopel.chat
Other
950 stars 405 forks source link

Unspecified `modes` parameter leads to confusing error #2509

Closed SnoopJ closed 9 months ago

SnoopJ commented 9 months ago

Description

The modes attribute of the CoreSection configuration object may be None under some circumstances where the attribute value is defaulted, as the old default ('B') was removed in 9e8a01d. This can cause failure elsewhere in the bot when membership against the modes attribute is checked.

The change in the default behavior seems very deliberate and this may have just slipped past us (I'll let @dgw weigh in on that), but even if this error is the intended behavior, we should be able to produce a better error report in this case.

Reproduction steps

Note: I am reporting on behalf of user Puzfire from IRC. In lieu of a reproduction, channel log and user paste (from 24 Sept 2023) are given below:

IRC log ``` 09:08 hey im trying out newest git version, on freebsd 13.2 i get some error i cant really pinpoint where to go to fix: https://paste.sh/7OXnqSuq#dbyfICah9GOltcGGsanjsjfX its related to botmode not in bot.config.core.modes it seems.. maybe one here can tell me 09:08 <+Sopel> [url] paste.sh · encrypted pastebin | paste.sh 09:09 i provided the cfg and the connect output 15:07 <+SnoopJ> Looks like `bot.config.core.modes` is None and should not be, it smells like a bug on our end 15:33 <+SnoopJ> Puzfire, are the `connect string:` and `###…` lines part of your actual config file? The former looks kinda weird to me 16:00 <+SnoopJ> It could also be illustrative to see what the raw IRC traffic looks like if you are willing to enable the `log_raw` config option and re-run, it's possible there's some weirdness going on when negotiating ISUPPORT with the server (but I kinda doubt this) 16:20 <+xrl> Oh... the previous version of `core.modes` was `'B'`, but now the default is `None`. https://github.com/sopel-irc/sopel/blob/master/sopel/config/core_section.py#L952C8-L952C8 16:20 <+Sopel> [GitHub] [sopel-irc/sopel] sopel/config/core_section.py @ master | L952: modes = ValidatedAttribute('modes') 16:20 <+xrl> That's why... 16:20 <+xrl> Should be easy enough to fix. 16:20 <+xrl> And to test. ```
User's config/log paste ``` ~/.sopel/default.cfg [core] nick = pybot host = 172.16.1.7 use_ssl = true verify_ssl = false port = 9977 owner = Meta auth_method = server auth_password = Password channels = "#CHAT", "#Staff", prefix = ! user = service flood_burst_lines = 100 flood_empty_wait = 0.5 flood_refill_rate = 2 commands_on_connect = connect string: #################################################### $ sopel start Warning: FreeBSD is an uncommon operating system platform. Sopel should still work, but please contact Sopel's developers if you experience issues. Sopel 8.0.0.dev0 (running on Python 3.9.18) https://sopel.chat/ Loaded config file: /home/ircbot/.sopel/default.cfg [2023-09-24 12:59:31,509] sopel.bot INFO - Loading plugins... [2023-09-24 12:59:31,532] sopel.bot INFO - Plugin loaded: admin [2023-09-24 12:59:31,534] sopel.bot INFO - Plugin loaded: announce [2023-09-24 12:59:31,548] sopel.bot INFO - Plugin loaded: adminchannel [2023-09-24 12:59:31,550] sopel.bot INFO - Plugin loaded: countdown [2023-09-24 12:59:31,992] sopel.bot INFO - Plugin loaded: help [2023-09-24 12:59:32,000] sopel.bot INFO - Plugin loaded: coretasks [2023-09-24 12:59:32,000] sopel.bot INFO - Registered 5 plugins, 0 failed, 0 disabled [2023-09-24 12:59:32,002] asyncio DEBUG - Using selector: KqueueSelector [2023-09-24 12:59:32,020] sopel.irc INFO - Connected, initiating setup sequence [2023-09-24 12:59:32,022] sopel.bot INFO - Client capability negotiation list: inspircd.org/poison, tls [2023-09-24 12:59:32,022] sopel.coretasks INFO - No capability negotiation. [2023-09-24 12:59:33,115] sopel.coretasks INFO - Enabled client capabilities: [2023-09-24 12:59:33,116] sopel.coretasks INFO - No custom command to execute. [2023-09-24 12:59:33,117] sopel.coretasks INFO - Received RPL_MYINFO from server: pybot, myircserver, InspIRCd-3 [2023-09-24 12:59:33,118] sopel.bot ERROR - Unexpected TypeError (argument of type 'NoneType' is not iterable) from Tessier-Ashpool.cbl. Message was: are supported by this server Traceback (most recent call last): File "/usr/home/ircbot/sopel/sopel/bot.py", line 699, in call_rule rule.execute(sopel, trigger) File "/usr/home/ircbot/sopel/sopel/plugins/rules.py", line 1262, in execute exit_code = self._handler(bot, trigger) File "/usr/home/ircbot/sopel/sopel/coretasks.py", line 466, in handle_isupport if botmode not in bot.config.core.modes: TypeError: argument of type 'NoneType' is not iterable [2023-09-24 12:59:33,142] sopel.coretasks INFO - Joining 2 channels (with JOIN throttle OFF); this may take a moment. [core] nick = pybot host = 172.16.1.7 [2023-09-24 12:59:33,144] sopel.coretasks INFO - Channel joined: #Chat [2023-09-24 12:59:33,145] sopel.coretasks INFO - Channel's topic updated: #Chat [2023-09-24 12:59:33,163] sopel.coretasks INFO - Channel joined: #STAFF [2023-09-24 12:59:33,164] sopel.coretasks INFO - Channel's topic updated: #STAFF [2023-09-24 12:59:33,166] sopel.coretasks INFO - Updated mode for channel: #Chat [2023-09-24 12:59:33,186] sopel.coretasks INFO - Updated mode for channel: #STAFF ```

Expected behavior

No error is issued, or a better error report is issued explaining that the parameter needs to be manually configured.

Relevant logs

No response

Notes

No response

Sopel version

274470e

Installation method

pip install

Python version

No response

Operating system

No response

IRCd

No response

Relevant plugins

No response

SnoopJ commented 9 months ago

As @Exirel pointed out on IRC, we will also need a regression test for this bug if the error is not the intended behavior.

dgw commented 9 months ago

Guess I didn't use one of the approved closing keywords in #2510, whoops. This should be fixed now.