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

CustomWebhook block type not found on Automation action #13282

Open
4 tasks done
robfreedy opened this issue May 8, 2024 · 2 comments
Open
4 tasks done

CustomWebhook block type not found on Automation action #13282

robfreedy opened this issue May 8, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@robfreedy
Copy link
Contributor

robfreedy commented May 8, 2024

First check

  • I added a descriptive title to this issue.
  • I used the GitHub search to find a similar issue and didn't find it.
  • I searched the Prefect documentation for this issue.
  • I checked that this issue is related to Prefect and not one of its dependencies.

Bug summary

Send a Notification Automation Action with CustomWebhook block fails after being triggered because the Block type could not be found. The CustomWebhook block does not exist out of the box in Prefect Cloud, so the block had to be registered to the workspace.

Reproduction

  1. Register the Custom Webhook block using the command and python code below
  2. Create the block by running the python code below
  3. Create an automation with any trigger (used flow run state as completed for this example)
  4. Set the Automation Action to "Send a notification" and specify the created Custom Webhook Block for the block. Save the automation.
  5. Trigger the automation.

Creating the block:

integration_key = "some_secret"
    CustomWebhookNotificationBlock(
        name="custom-notifier",
        url="https://a-url-like-pager-duty",
        json_data={
            "routing_key": "{{routing_key}}",
            "event_action": "trigger",
            "payload": "{{body}}"},
        secrets={"routing_key": integration_key,
                 "payload": None
                 }
    ).save("custom-webhook-test-block", overwrite=True)

Command to register the block

prefect block register --file test-block.py

Error

This was taken from the event payload of the Automation action Failed event (see complete payload in screenshot below).

"The notification block was invalid: KeyError(\"No class found for dispatch key 'custom-webhook' in registry for type 'Block'.\")"

Versions

Version:             2.16.6
API version:         0.8.4
Python version:      3.11.8
Git commit:          3fecd435
Built:               Sat, Mar 23, 2024 4:06 PM
OS/Arch:             darwin/arm64
Profile:             default
Server type:         cloud

Additional context

Automation Action Failed event payload:
image

@robfreedy robfreedy added bug Something isn't working needs:triage Needs feedback from the Prefect product team labels May 8, 2024
@zangell44
Copy link
Collaborator

zangell44 commented May 8, 2024

@robfreedy at the moment only known system block types (like Webhook) can be used in Automation actions.

We don't have any way to instantiate CustomWebhookNotificationBlock server side, only metadata about the block definition.

Happy to chat through a feature request if you think there's value.

Seems like at minimum we could explain the above in our Automations action error message.

@zangell44 zangell44 removed the needs:triage Needs feedback from the Prefect product team label May 8, 2024
@robfreedy
Copy link
Contributor Author

robfreedy commented May 8, 2024

Gotcha, that makes sense. I could see this experience being confusing based on what is exposed in the Cloud UI just because there could be any number of custom blocks with the "notify" tag on them when setting the block for the "Send a Notifaction" action that would not be valid since there is no way to instantiate the CustomWebhookNotificationBlock or any custom block type.

I would maybe propose we either:

  • Have a set list of "notification" block types that can be set on the Automation Action for sending a notification.
  • Support any block type (including custom block types) in the automation action (larger feature request/discussion)

cc: @masonmenges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants