<@ULVA73B9P> I upgraded appraise to 1.9.5 to fix M...
# ask-marvin
a
@Marvin I upgraded appraise to 1.9.5 to fix MS Teams Block compatibility but now I'm encountering another error with my automation:
Copy code
TypeError(\"unsupported operand type(s) for +=: 'frozenset' and 'tuple'\")"
m
thought for 150.9 seconds
Thanks for the details — this error lines up with a known compatibility change in Apprise 1.9.4+. What’s happening: - In Apprise 1.9.4,
apprise.NOTIFY_TYPES
changed from a
tuple
to a
frozenset
. - Older Prefect code tried to do
+=
on that value when initializing notification blocks, which raises:
TypeError: unsupported operand type(s) for +=: 'frozenset' and 'tuple'
- This was fixed in Prefect by adding a version-aware check for
frozenset
vs
tuple
. References: - Issue: TypeError with apprise 1.9.4 - PR: Fix TypeError with apprise 1.9.4 when adding notify type - (For 2.x backport context) PR: Fix anyio/apprise compatibility issues How to fix it: - Best: Upgrade Prefect to a version that includes the fix (latest 3.x).
Copy code
pip install -U prefect
- If you can’t upgrade Prefect immediately, pin Apprise back to 1.9.3 (before the change to
frozenset
):
Copy code
pip install "apprise==1.9.3"
Note: This may impact your MS Teams compatibility if you were relying on changes in 1.9.4+. Could you share: - Your Prefect version (
python -c "import prefect, apprise; print(prefect.__version__, apprise.__version__)"
) - A short traceback snippet showing where this is thrown (likely during notification block init in your automation) With that, I can confirm whether you’re on a Prefect version that already contains the fix or if an upgrade/pin is the quickest path.
a
@Marvin Can you point me to where this version aware check was made on Prefect?
m
thought for 87.6 seconds
Yes — it was added in Prefect’s notification blocks. The change landed in PR #18697 and updates
src/prefect/blocks/notifications.py
to handle
apprise.NOTIFY_TYPES
being a
frozenset
(Apprise ≥ 1.9.4) or a
tuple
(older Apprise). Direct links: - PR diff: Fix TypeError with apprise 1.9.4 when adding notify type - Permalink to the code lines referenced in the original report: notifications.py L36–L42 The logic added looks like this (simplified):
Copy code
import apprise
from prefect.blocks.notifications import PREFECT_NOTIFY_TYPE_DEFAULT

# Handle Apprise >= 1.9.4 (frozenset) vs older Apprise (tuple)
if isinstance(apprise.NOTIFY_TYPES, frozenset):
    apprise.NOTIFY_TYPES = apprise.NOTIFY_TYPES | {PREFECT_NOTIFY_TYPE_DEFAULT}
else:
    apprise.NOTIFY_TYPES += (PREFECT_NOTIFY_TYPE_DEFAULT,)
For users on the 2.x EOL branch, the same compatibility fix was backported in PR #18741.
a
@Marvin Thanks, that fixed it. Another question, how do you call the exception or error in the automation body
m
thought for 343.3 seconds
Great question. In Prefect 3.x Automations, the message body is a Jinja template rendered against the event payload. For failures, the human-readable error is typically in the state’s message. You can reference it with: - Flow-run events:
{{ payload.state.message }}
- Task-run events:
{{ payload.state.message }}
Example templates:
Copy code
Flow failed: {{ payload.flow_run.name }}
Status: {{ payload.state.type }}
Error: {{ payload.state.message }}
Run ID: {{ payload.flow_run.id }}
Link: {{ payload.flow_run.url }}
Copy code
Task failed: {{ payload.task_run.name }} in {{ payload.flow_run.name }}
Status: {{ payload.state.type }}
Error: {{ payload.state.message }}
Run: {{ payload.flow_run.name }} ({{ payload.flow_run.id }})
Notes and tips: - Full tracebacks are not included in the event payload. For deep details, link to the run page (
{{ payload.flow_run.url }}
) or use a custom webhook/flow to fetch logs or state details from the API. - Available keys differ by event type (flow-run vs task-run), but common fields include: -
payload.flow_run.name
,
payload.flow_run.id
,
payload.flow_run.url
-
payload.task_run.name
,
payload.task_run.id
-
payload.state.type
,
payload.state.name
,
payload.state.message
- To see exactly what’s available for your event, add a temporary Call Webhook action to a service like webhook.site and inspect the JSON payload your automation sends. Docs for reference: - Creating automations - Access parameters in templates - Notification blocks API If you tell me whether you’re templating Slack, Teams, or email, I can tailor a ready-to-paste example.