Hi all, I am trying to pass a CloudEvent to my flo...
# prefect-cloud
c
Hi all, I am trying to pass a CloudEvent to my flow from an automation which is tied to a webhook receiving a CloudEvent and I can't figure out how to get the payload to come in as a valid dictionary instead of a string. Webhook is configured with:
Copy code
{{ body|from_cloud_event(headers) }}
Automation sets the event paramenter for the example_flow like this:
Copy code
{{ event.payload }}
the flow is as follows:
Copy code
@flow(name="Example Flow", log_prints=True)
def example_flow(event: Any) -> None:
    print(type(event))
    print(event)


if __name__ == "__main__":
    example_flow.serve("Example Flow")
What I expect when I print the type of `event`: <class 'dict'> What I see: <class 'str'>
n
hi @Carlos Escobedo I think right now you'd need to
json.loads(event)
to get the
dict
i think there's an issue for this
c
Hi @Nate! Thank you for the fast response 🙂 I have used the json.loads() in other flows as a workaround
I was hoping to be able to set the event type hint to CloudEvent or Dict to get validation earlier on. Could you point me to the issue number so I can follow it?
n
ah i was thinking of an internal ticket related to this, but I just created this issue please feel free to chime in on the issue if you think i've missed some detail
🎉 1
🙌 1
c
@Jacob Garrett So you can follow this issue as well
🙏 1
Hi @Nate, I recently saw that this change went in and I wanted to know how I can actually make it work in the UI: https://github.com/PrefectHQ/prefect/pull/15132