zulip / python-zulip-api

Python library for the Zulip API.
https://zulip.com/api/
Apache License 2.0
364 stars 368 forks source link

Remove unnecessary "sender" in request data #782

Closed i-ky closed 1 year ago

i-ky commented 1 year ago

I've experienced that rss-bot works fine when using config file, but fails when --site, --api-key, and --user are provided via command line. The error is the following:

{'result': 'error', 'msg': 'Invalid mirrored message', 'code': 'BAD_REQUEST'}

Debugging shows that in the latter case rss-bot calls zulip.Client.send_message() with "sender" field in message_data. In the former case "sender" is None. Clearly, it is a bug that rss-bot's behaviour depends on --user being provided on the command line.

"sender" field in request causes this exception on the server side. Judging by surrounding code, "sender" is only expected together with a specific set of clients. rss-bot uses a different one: https://github.com/zulip/python-zulip-api/blob/1b8f1d6e5170b49fd370e74b37b2fc0b936d22a4/zulip/integrations/rss/rss-bot#L204 Therefore I think, that providing "sender" is totally unnecessary.

timabbott commented 1 year ago

Merged, after copying your very nice PR description into the commit message, thanks @i-ky!