<@ULVA73B9P> looking to make an automation with a ...
# marvin-ai
p
@Marvin looking to make an automation with a yaml file. Here is the yaml for this automation:
Copy code
- name: notify-local-workpool-is-down
    description: Sends a slack message when our local-work-pool has been down for over 60 seconds
    enabled: true
    trigger:
      type: event
      match:
        prefect.resource.id:
          - prefect.work-pool.local-work-pool
      match_related: {}
      after:
        - prefect.work-pool.not-ready
        - prefect.work-pool.not_ready
      expect:
        - prefect.work-pool.paused
        - prefect.work-pool.ready
      for_each:
        - prefect.resource.id
      posture: Proactive
      threshold: 1
      within: 60
    actions:
      - type: send-notification
        block_document_id: slack-webhook-etl-testing-failures
        subject: Prefect work pool '{{ work_pool.name }}' has remained in status '{{ work_pool.status }}' for at least 1 minute!
        body: |
          Name: {{ work_pool.name }}
          Status: {{ work_pool.status }}
Getting errors like:
Copy code
Failed to create 1 automation(s):
  - notify-local-workpool-is-down: 18 validation errors for AutomationCore
actions.0.DoNothing.type
  Input should be 'do-nothing'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.function-after.type
  Input should be 'run-deployment'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.function-after.type
  Input should be 'pause-deployment'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.function-after.type
  Input should be 'resume-deployment'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.CancelFlowRun.type
  Input should be 'cancel-flow-run'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.ChangeFlowRunState.type
  Input should be 'change-flow-run-state'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.ChangeFlowRunState.state
  Field required
    For further information visit <https://errors.pydantic.dev/2.12/v/missing>
actions.0.function-after.type
  Input should be 'pause-work-queue'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.function-after.type
  Input should be 'resume-work-queue'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.SendNotification.block_document_id
  Input should be a valid UUID, invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `s` at 1
    For further information visit <https://errors.pydantic.dev/2.12/v/uuid_parsing>
actions.0.CallWebhook.type
  Input should be 'call-webhook'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.CallWebhook.block_document_id
  Input should be a valid UUID, invalid character: expected an optional prefix of `urn:uuid:` followed by [0-9a-fA-F-], found `s` at 1
    For further information visit <https://errors.pydantic.dev/2.12/v/uuid_parsing>
actions.0.function-after.type
  Input should be 'pause-automation'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.function-after.type
  Input should be 'resume-automation'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.SuspendFlowRun.type
  Input should be 'suspend-flow-run'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.PauseWorkPool.type
  Input should be 'pause-work-pool'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.ResumeWorkPool.type
  Input should be 'resume-work-pool'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
actions.0.DeclareIncident.type
  Input should be 'declare-incident'
    For further information visit <https://errors.pydantic.dev/2.12/v/literal_error>
m
thought for 475.8 seconds
Thanks for sharing the YAML and the error output — that error is super telling. What’s going wrong - The action is being validated against all possible action types; the only one that matters in your case is SendNotification. The key error is: - actions.0.SendNotification.block_document_id: Input should be a valid UUID - In Prefect 3.x, the
send-notification
action expects
block_document_id
to be a UUID, not a block name/slug. That’s why
slack-webhook-etl-testing-failures
fails validation. A couple of other notes: - Event names should use hyphens, not underscores. Use
prefect.work-pool.not-ready
,
prefect.work-pool.ready
,
prefect.work-pool.paused
. - Your trigger structure otherwise looks good for a proactive “if it stays not ready for 60s” alert. How to get the block UUID - Via CLI:
Copy code
prefect block ls
  prefect block inspect <BLOCK_TYPE_SLUG>/<BLOCK_NAME>
Look for the “ID” in the inspect output and use that as
block_document_id
. - Or via the UI: open the block and copy its ID. Example corrected YAML Replace the placeholder UUID with your SlackWebhook block’s actual UUID.
Copy code
- name: notify-local-workpool-is-down
  description: Sends a slack message when our local-work-pool has been down for over 60 seconds
  enabled: true
  trigger:
    type: event
    match:
      prefect.resource.id:
        - prefect.work-pool.local-work-pool
    after:
      - prefect.work-pool.not-ready
    expect:
      - prefect.work-pool.ready
      - prefect.work-pool.paused
    for_each:
      - prefect.resource.id
    posture: Proactive
    threshold: 1
    within: 60
  actions:
    - type: send-notification
      block_document_id: "00000000-0000-0000-0000-000000000000"  # <-- replace with your block UUID
      subject: "Prefect work pool '{{ work_pool.name }}' has remained in status '{{ work_pool.status }}' for at least 1 minute!"
      body: |
        Name: {{ work_pool.name }}
        Status: {{ work_pool.status }}
If you prefer to avoid
work_pool.*
in templates, you can use event-scoped variables like: -
{{ event.resource.id }}
and
{{ event.resource.name }}
Helpful docs - Automations and event triggers: Event triggers (Prefect 3) - Notification blocks (Slack webhook etc.): Notification blocks API If you share the block slug you’re using, I can help you derive the correct
prefect block inspect
command to grab the UUID.
p
ok great! I was looking for a way to put these into a ci/cd process but that looks like more trouble than it's worth. Thank you!