Skip to content

Not enough values to unpack for certain NAMES entries when behind ZNC #2311

@dgw

Description

@dgw

Description

I just updated our official instance to current master (8d077a0) and observed some errors in its startup log upon reconnecting to Libera, apparently related to NAMES replies not always containing the hostmask for every value.

Reproduction steps

  1. Enable both raw and debug logging, for completeness
  2. Connect Sopel to Libera via ZNC, preferably in a channel with a decent user count such as #sopel
  3. Observe "Not enough values to unpack" errors from certain lines in the initial NAMES responses

Expected behavior

Sopel should not error, as this means it will fail to process the whole line. Regardless of whether Libera's IRCd is breaking spec by failing to always include hostmasks in NAMES when the relevant capability is enabled, Sopel should gracefully handle this case.

Relevant logs

# just one of several NAMES lines that triggered this, all including at least
# one nick that had no [email protected] after it

[2022-06-24 06:03:33,451] sopel.bot            ERROR    - Unexpected error (not enough values to unpack (expected 2, got 1)) from
  silver.libera.chat at 2022-06-24 06:03:33.450989. Message was: [email protected] Benett
  Chex!~Chex@user/chex +Duckle!~Duckle@user/duckle +Exirel!sid255844@sopel-irc/rockstars/Exirel Foxy!foxy@user/foxy
  GNU\Andrew!Andrew@user/AndrewYu +HumorBaby!HumorBaby@sopel-irc/rockstars/HumorBaby Legomannetje
  Noisytoot!~noisytoot@sourcehut/user/noisytoot [email protected] RhinosF1!sid339563@miraheze/RhinosF1
  +RustyCloud Sario!sid356235@fosshost/cdo/Sario ShArkZ SnoopJ!~snoopj@user/snoopj +Sopel!Sopel@sopel/official/bot
Traceback (most recent call last):
  File "/home/sopel/sopel-git/sopel/bot.py", line 620, in call_rule
    rule.execute(sopel, trigger)
  File "/home/sopel/sopel-git/sopel/plugins/rules.py", line 1117, in execute
    exit_code = self._handler(bot, trigger)
  File "/home/sopel/sopel-git/sopel/coretasks.py", line 524, in handle_names
    name, mask = name.rsplit('!', 1)
ValueError: not enough values to unpack (expected 2, got 1)

# relevant raw log
# note attempted PRIVMSG of error to the server hostname, which we might also consider trying to avoid doing

2022-06-24 06:03:33,449 <<	'@time=2022-06-24T06:03:33.378Z :silver.libera.chat 353 Sopel = #1472 
  :[email protected] Benett Chex!~Chex@user/chex +Duckle!~Duckle@user/duckle
  +Exirel!sid255844@sopel-irc/rockstars/Exirel Foxy!foxy@user/foxy GNU\\Andrew!Andrew@user/AndrewYu
  +HumorBaby!HumorBaby@sopel-irc/rockstars/HumorBaby Legomannetje Noisytoot!~noisytoot@sourcehut/user/noisytoot
  [email protected] RhinosF1!sid339563@miraheze/RhinosF1 +RustyCloud Sario!sid356235@fosshost/cdo/Sario ShArkZ
  SnoopJ!~snoopj@user/snoopj +Sopel!Sopel@sopel/official/bot\r\n'
2022-06-24 06:03:33,454 >>	'PRIVMSG silver.libera.chat :Unexpected error (not enough values to unpack (expected 2,
  got 1)) from silver.libera.chat at 2022-06-24 06:03:33.450989. Message was: [email protected]
  Benett Chex!~Chex@user/chex +Duckle!~Duckle@user/duckle +Exirel!sid255844@sopel-irc/rockstars/Exirel
  Foxy!foxy@user/foxy GNU\\Andrew!Andrew@user/AndrewYu +HumorBaby!HumorBaby@sopel-irc/rockstars/HumorBaby
  Legomannetje Noisytoot!~noisytoot@sourcehut/user/noisytoot [email protected] RhinosF1!sid33956\r\n'

Notes

Likely related to #2102, though I have not taken the time tonight for anything like a git bisect to prove it. Honestly, the relevant code seems obvious enough to skip that step.

I have amended the report to include that Sopel was connecting via ZNC, a fact I forgot about initially.

Sopel version

8d077a0

Installation method

pip install

Python version

4.9

Operating system

No response

IRCd

solanum-1.0-dev via ZNC 1.8.2

Relevant plugins

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions