Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wikipedia: parse error for template link with fragment #2167

Closed
dgw opened this issue Jul 24, 2021 · 1 comment · Fixed by #2168
Closed

wikipedia: parse error for template link with fragment #2167

dgw opened this issue Jul 24, 2021 · 1 comment · Fixed by #2168
Assignees
Labels
Bug Things to squish; generally used for issues
Milestone

Comments

@dgw
Copy link
Member

dgw commented Jul 24, 2021

Description

If someone links a template URL with a section fragment, Sopel outputs an unexpected error.

Logs

[2021-07-24 17:12:47,036] sopel.bot            ERROR    - Unexpected error ('parse') from dgw at 2021-07-24
22:12:47.036637. Message was: https://en.wikipedia.org/wiki/Template:Infobox_company#TemplateData
Traceback (most recent call last):
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/sopel/bot.py", line 757, in call_rule
    rule.execute(sopel, trigger)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/sopel/plugins/rules.py", line 1057,
  in execute
    exit_code = self._handler(bot, trigger)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/sopel/plugins/rules.py", line 1608,
  in execute_handler
    return handler(bot, trigger, match=trigger)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/sopel/modules/wikipedia.py", line 256,
  in mw_info
    say_section(bot, trigger, match.group(1), unquote(match.group(2)), unquote(match.group(3)))
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/sopel/modules/wikipedia.py", line 204,
  in say_section
    snippet = mw_section(server, query, section)
  File "/data/data/com.termux/files/usr/lib/python3.9/site-packages/sopel/modules/wikipedia.py", line 240,
  in mw_section
    parser.feed(data['parse']['text']['*'])
KeyError: 'parse'

Environment

  • Sopel .version: 7.1.2
  • Sopel installed via: pip
  • Python version: 3.9.6
  • Operating system: Termux (but was first reported by @RhinosF1 on a different platform)
  • IRCd /version: plexus-4(hybrid-8.1.20)(20200510_0-610). irc.rizon.ca TS6ow
  • Relevant plugins: wikipedia

Notes

The same template URL with no fragment yields a perfectly functional, but useless, empty snippet.

<SopelTest> [wikipedia] Template:Infobox company | ""
@dgw dgw added the Bug Things to squish; generally used for issues label Jul 24, 2021
@dgw dgw added this to the 7.1.3 milestone Jul 24, 2021
@dgw
Copy link
Member Author

dgw commented Jul 24, 2021

Bit more digging in API docs and test requests, and I should have a patch for this tonight.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Things to squish; generally used for issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant