Michael Schwartz
07/08/2025, 1:35 AM{
"id": "0686c680-6e40-70d8-8000-7a475bb82db3",
"account": "1f68ce6c-568d-4d7a-ae99-9641099300bd",
"event": "prefect-cloud.webhook.failed",
"occurred": "2025-07-08T00:36:22.890Z",
"payload": {
"method": "POST",
"headers": {
"host": "api.prefect.cloud",
"user-agent": "python-requests/2.32.3",
"accept-encoding": "gzip, deflate",
"accept": "*/*",
"content-type": "application/json",
"content-length": "1408",
"x-request-id": "3a68f983-ef4a-457d-ad4c-277c374fc0de"
},
"body": "{\"data\": [{\"uom\": \"gram\", \"brand\": \"PINNACLE VALLEY FARMS\", \"state\": \"Vermont\", \"source\": \"dutchie\", \"strain\": \"N/A\", \"thc_mg\": \"100\", \"menu_id\": \"16a2482a571ffea0cdb34e7d4545c8db\", \"segment\": \"Soft Candy\", \"category\": \"Edibles\", \"brand_src\": \"Pinnacle Valley Farms\", \"image_url\": \"<https://askhoodie.com/cdn-cgi/image/quality=50/https://data-item-images.s3.us-east-2.amazonaws.com/success/2de24aa74f2be5fbcd1f1db9bfd5ace0>\", \"item_name\": \"Blue Raspberry 100mg Hash Rosin Gummies\", \"__record_id\": \"932cbe36c70ee680d093c969dcdc755c__unifyd_master_3986919\", \"subsegment\": \"Gummies\", \"description\": \"Delightful Hash Rosin Gummies from our friends at Pinnacle Valley Farms. Blue Raspberry is their \\\"Calming\\\" blend.\\n\\n5mg THC per gummy, 20 gummies per pack (100mg)\\n\\nVEGAN!\\n\\nIngredients: Sugar, Tapioca syrup, Water (Distilled), Pectin, Natural flavor, Citric acid, Sodium citrate, MCT, Hash rosin, Natural & artificial colors\", \"dict_flavor\": \"Blue Raspberry\", \"variant_url\": \"<https://dutchie.com/dispensary/cann-maxx/product/pinnacle-valley-farms-blue-raspberry>\", \"category_src\": \"EDIBLES\", \"parent_brand\": \"PINNACLE VALLEY FARMS\", \"sub_category\": \"gummies\", \"cannabis_type\": \"INDICA\", \"dict_pack_size\": \"20 pack\", \"pos_product_id\": \"153139\", \"product_id_src\": \"af1b4a49f6075dfec8d4669652c307fb\", \"product_presentation\": \"100.00 mg\", \"dict_concentrate_type\": \"Rosin\", \"category_src_normalized\": \"Edibles\"}]}",
"rendered": {
"event": "pim.unifyd.catsy",
"resource": {
"prefect.resource.id": "pim.unifyd.catsy.handle",
"payload": {
"data": [
{
"__record_id": "932cbe36c70ee680d093c969dcdc755c__unifyd_master_3986919",
"brand": "PINNACLE VALLEY FARMS",
"brand_src": "Pinnacle Valley Farms",
"cannabis_type": "INDICA",
"category": "Edibles",
"category_src": "EDIBLES",
"category_src_normalized": "Edibles",
"description": "Delightful Hash Rosin Gummies from our friends at Pinnacle Valley Farms. Blue Raspberry is their \"Calming\" blend.\n\n5mg THC per gummy, 20 gummies per pack (100mg)\n\nVEGAN!\n\nIngredients: Sugar, Tapioca syrup, Water (Distilled), Pectin, Natural flavor, Citric acid, Sodium citrate, MCT, Hash rosin, Natural & artificial colors",
"dict_concentrate_type": "Rosin",
"dict_flavor": "Blue Raspberry",
"dict_pack_size": "20 pack",
"image_url": "<https://askhoodie.com/cdn-cgi/image/quality=50/https://data-item-images.s3.us-east-2.amazonaws.com/success/2de24aa74f2be5fbcd1f1db9bfd5ace0>",
"item_name": "Blue Raspberry 100mg Hash Rosin Gummies",
"menu_id": "16a2482a571ffea0cdb34e7d4545c8db",
"parent_brand": "PINNACLE VALLEY FARMS",
"pos_product_id": "153139",
"product_id_src": "af1b4a49f6075dfec8d4669652c307fb",
"product_presentation": "100.00 mg",
"segment": "Soft Candy",
"source": "dutchie",
"state": "Vermont",
"strain": "N/A",
"sub_category": "gummies",
"subsegment": "Gummies",
"thc_mg": "100",
"uom": "gram",
"variant_url": "<https://dutchie.com/dispensary/cann-maxx/product/pinnacle-valley-farms-blue-raspberry>"
}
]
}
}
},
"compiled": null,
"reason": "1 validation error for Event\nresource.payload\n Input should be a valid string [type=string_type, input_value={'data': [{'__record_id':...farms-blue-raspberry'}]}, input_type=dict]\n For further information visit <https://errors.pydantic.dev/2.10/v/string_type>"
},
"received": "2025-07-08T00:36:22.890Z",
"related": [],
"resource": {
"prefect.resource.id": "prefect-cloud.webhook.283c8f61-321f-4336-99a8-b679b2206dbf",
"prefect.resource.name": "Upsert Catsy Products"
},
"workspace": "8f854e6c-4fe7-49b7-860c-8f2e7973c905"
}
Marvin
07/08/2025, 1:36 AMMarvin
07/08/2025, 1:36 AMInput should be a valid string [type=string_type, input_value={'data': [...]}, input_type=dict]
To fix this, you'll need to modify your webhook template to properly handle the JSON payload. Here are two approaches:
1. If you're using a Prefect webhook block, you can add a template that converts the dictionary to a string:
python
from prefect.blocks.webhook import Webhook
webhook = Webhook(
url="your_webhook_url",
template="""
{
"event": "pim.unifyd.catsy",
"resource": {
"prefect.resource.id": "pim.unifyd.catsy.handle",
"payload": {{ json.dumps(body) }}
}
}
"""
)
2. If you're using the webhook directly in a flow, you can format the payload like this:
python
import json
from prefect import flow
import httpx
@flow
def send_webhook():
payload = {
"event": "pim.unifyd.catsy",
"resource": {
"prefect.resource.id": "pim.unifyd.catsy.handle",
"payload": json.dumps(your_data) # Convert the data dict to a JSON string
}
}
response = <http://httpx.post|httpx.post>("your_webhook_url", json=payload)
return response
The key change is using json.dumps()
to convert the nested data dictionary to a string, which should satisfy the validation requirements of the receiving endpoint.
Also, make sure your webhook endpoint is configured to accept and parse JSON payloads by setting the appropriate content-type header:
python
headers = {
"Content-Type": "application/json"
}
Let me know if you need help implementing either of these approaches or if you're using a different webhook configuration method.