Repository navigation
Conversation
When a bot is run by module name with --provision, the error message
printed a literal '{}' instead of the bot's name, since the string was
never formatted.
Previously, when zulip-run-bot couldn't find a bot, it only printed "Could not load bot module", without saying what it had tried. This was confusing for people running their own bots, who usually don't know that a bare name is only looked up among the bundled bots and then as an importable module. The error now names the bot, lists the places that were checked, and suggests passing the path to the bot's .py file. Registry lookups (-r) get their own message. Fixes part of zulip#636.
Collaborator
Author
|
The Debian 11 job fails while provisioning the server, with 404s from deb.debian.org for bullseye packages. That looks unrelated to this change, since bullseye has reached end of life and its packages have moved to the archive. The other jobs pass. |
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.
This improves
zulip-run-bot's error when it can't find a bot, which is what people hit in the chat threads linked from #636, and fixes a small bug in a nearby error message.Fixes: Part of #636. The docs side is still open; #925 separately documents loading custom bots from files for the botserver.
Commit 1 fills in the bot name in the
--provisionerror for bots run by module name, which printed a literal'{}':Commit 2 makes the "Could not load bot module" error say where it looked and what to try.
Before:
After (bot at
~/mybot/mybot.py, run from another directory):With
-r, there's a separate message, since only the registry is checked in that case.I've left out changes to how bot modules are searched for, since that needs more discussion. I also didn't change the
AttributeError: ... no attribute 'handler_class'you get when PYTHONPATH points at the folder containing the bot, which is another confusing case from the chat threads. I'm happy to look at that separately.How did you test this PR?
Added tests in
test_run.pyfor both changes, and checked that they fail without the fixes. Ranpytest zulip_bots(416 passed), andruff check,ruff format --checkandmypyon the changed files. I also reproduced the original error locally with a copy of helloworld at~/mybot/mybot.py, and checked the new output shown above.Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: