Skip to content

wiktionary: regression in handling unknown words #9

@dgw

Description

@dgw

sopel-wikimedia 1.0.0's version of the wiktionary plugin outputs an uncaught exception when queried for words that don't exist on the wiki:

14:39:01 <dgw> .wt jfoawyeriasf
14:39:02 <Yuzu> Unexpected HTTPError (404 Client Error: Not Found for url:
                https://en.wiktionary.org/w/index.php?title=jfoawyeriasf&printable=yes) from dgw.
                Message was: .wt jfoawyeriasf
14:39:12 <dgw> .version wiktionary
14:39:12 <Yuzu> [version] wiktionary v1.0.0

Compare to Sopel 8.0.4's built-in wiktionary:

14:38:49 <dgw> .wt jfoawyeriasf
14:38:50 <Sopel> dgw: Couldn't get any definitions for jfoawyeriasf.
14:39:01 <dgw> .version wiktionary
14:39:01 <Sopel> [version] wiktionary v8.0.4 (built in)

The standalone plugin has a response.raise_for_status() call not present in the original, but no corresponding try/except block to catch the error where wikt() is called.

Full traceback
[2026-01-18 20:39:01,901] sopel.bot            ERROR    - Unexpected HTTPError (404 Client Error: Not Found for url: https://en.wiktionary.org/w/index.php?title=jfoawyeriasf&printable=yes) from dgw. Message was: .wt jfoawyeriasf
Traceback (most recent call last):
  File "/home/dgw/.local/lib/python3.11/site-packages/sopel/bot.py", line 704, in call_rule
    rule.execute(sopel, trigger)
  File "/home/dgw/.local/lib/python3.11/site-packages/sopel/plugins/rules.py", line 1273, in execute
    exit_code = self._handler(bot, trigger)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/dgw/.local/lib/python3.11/site-packages/sopel_wikimedia/wiktionary/plugin.py", line 28, in wiktionary
    _etymology, definitions = wikt(word)
                              ^^^^^^^^^^
  File "/home/dgw/.local/lib/python3.11/site-packages/sopel_wikimedia/wiktionary/impl.py", line 94, in wikt
    response.raise_for_status()
  File "/home/dgw/.local/lib/python3.11/site-packages/requests/models.py", line 1026, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://en.wiktionary.org/w/index.php?title=jfoawyeriasf&printable=yes

I initially thought this was a bug with handling spaces in the query, but I'm glad I held off opening the issue and took time to test a bit more.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions