Repository navigation
Pass the configured botname to NotifyMattermost - #23281
Conversation
MattermostWebhook declares a botname field and surfaces it in the UI block form, but block_initialization stopped passing it when it was rewritten to add the NotifyMattermost instance directly instead of going through .url(). Seven of the eight fields survived that rewrite; user=self.botname did not. With self.user unset, apprise falls back to the asset app_id when building the webhook payload (apprise/plugins/mattermost.py:646), so every message is signed with the asset name regardless of what the user configured. The field is accepted, persisted, and then discarded with no exception, warning, or log. The keyword is user= rather than botname=: NotifyMattermost does not take a botname argument, it declares botname as an alias of user and relays **kwargs to URLBase, which reads user. This restores what PrefectHQ#19780 established before the rewrite. Adds test_botname_is_passed_to_apprise to the existing TestMattermostWebhook class.
| token=self.token.get_secret_value(), | ||
| fullpath=self.path, | ||
| host=self.hostname, | ||
| user=self.botname, |
There was a problem hiding this comment.
🔍 Bug fix lacks issue discussion
This bug fix has no linked issue, despite the issue-first rule in contribution guidance. The cited earlier PR fixed the original defect, not this regression.
Was this helpful? React with 👍 or 👎 to provide feedback.
Merging this PR will not alter performance
Comparing Footnotes
|
The test read plugin.user, an apprise-internal attribute reached through the block's private _apprise_client. The contribution guide asks for tests that assert user-visible behavior rather than private implementation details. It now patches requests.post and asserts on payload["username"], which is the name Mattermost actually displays. Without the fix it fails with assert 'Apprise' == 'Prefect Bot' instead of assert None == 'Prefect Bot'.
|
Both points taken Issue opened at #23282 and linked above : the contribution guide asks for one beyond a doc or typo fix and I read the PR template's "small fix" wording too narrowly The test now patches On the red group from the first run : the two failures were in |
closes #23282
MattermostWebhookexposes abotnamefield, butblock_initializationnever passes it toNotifyMattermost. The name is accepted by pydantic, persisted on the block document, then dropped at send time no exception, no warning, no log line.In webhook mode the default, and the only mode this block can reach since it does not expose
modeapprise builds the sender name aspayload["username"] = self.user if self.user else self.app_id(apprise/plugins/mattermost.py:646). Withself.userunset, every message is signed with the asset name instead of the configured one.How it regressed
#19780 set
user=self.botnameon this exact call.block_initializationwas later rewritten to add the plugin instance directly instead of going through.url(), because apprise >= 1.9.9 stopped putting channels in the URL and renamedchannelstotargets. That rewrite kept seven of the eight fields and leftuser=self.botnamebehind. The comment above the call (notifications.py:747-749) documents the.url()andtargetschanges only.Why
user=and notbotname=NotifyMattermost.__init__takes nobotnamekeyword. apprise declares it as an alias ofuser(mattermost.py:225-227) and relays**kwargstoURLBase, which readsuser. Passingbotname=lands in**kwargsand is ignored the original bug #19780 fixed.Verification
The added test, plus the existing
test_notify_with_multiple_channelsas a witness, run against the patched source and against the source with the one line removed:Driving the plugin directly with
requests.postpatched, no network and no server:targetsandportare unchanged in both.The full
TestMattermostWebhookclass could not be run here: every test in it, including the five that predate this change, errors onRuntimeError: Timed out while attempting to connect to hosted test Prefect API(src/prefect/testing/fixtures.py:135). That is my environment, not this change, which is why the checks above were run outside the session fixture.Measured with
apprise==1.13.1(the pin isapprise>=1.13.0,<2.0.0).Noted while reproducing, out of scope
The fallback prints
Apprise, notPrefect Notifications.Apprise.add()given an already constructed plugin instance just appends it (apprise/apprise.py:308-310) without applying the asset, so theAppriseAssetbuilt atnotifications.py:760-764never reaches this plugin. Separate branding issue, untouched here happy to open a follow-up.Checklist
<link to issue>"botnamedescription is what is being restored; it is already accurate.mint.json. N/AAI tools were used to find this defect and draft this description. I understand the change, I kept it to one line, and I validated it locally as described above.