<@ULVA73B9P> I am getting this error ```{ "id":...
# ask-marvin
m
@Marvin I am getting this error
Copy code
{
  "id": "0686d5dc-4d24-74e0-8000-a25c7f861709",
  "account": "1f68ce6c-568d-4d7a-ae99-9641099300bd",
  "event": "prefect-cloud.webhook.failed",
  "occurred": "2025-07-08T18:04:52.821Z",
  "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": "1a66776c-5201-9755-85ef-bc683eeb2df6"
    },
    "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": [
          {
            "__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=[{'__record_id': '932cbe3...-farms-blue-raspberry'}], input_type=list]\n    For further information visit <https://errors.pydantic.dev/2.10/v/string_type>"
  },
  "received": "2025-07-08T18:04:52.821Z",
  "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"
what can i modify in my webhook or in the flow this triggers to avoid this pydantic error? this is my template
Copy code
{
  "event": "pim.unifyd.catsy",
  "resource": {
    "prefect.resource.id": "pim.unifyd.catsy.handle",
    "payload": {{ body.data | tojson }}
  }
}
m
โœ… thought for 8.0 seconds
Ah, a classic case of Pydantic being particular about its data types. The error is telling us that the webhook is expecting a string for
resource.payload
, but it's receiving a list. Let's fix this. You have two options: 1. Modify the webhook template to stringify the entire payload:
Copy code
json
{
  "event": "pim.unifyd.catsy",
  "resource": {
    "prefect.resource.id": "pim.unifyd.catsy.handle",
    "payload": {{ body.data | tojson | tojson }}
  }
}
Notice the double
tojson
filter - this will ensure the list is converted to a JSON string. 2. Modify your flow to expect and parse a JSON string. If you're using Pydantic models, your model should look something like:
Copy code
python
from pydantic import BaseModel

class WebhookPayload(BaseModel):
    event: str
    resource: dict[str, str]  # or create a nested model for resource
Then in your flow, you can parse the string back into a list:
Copy code
python
import json

@flow
def handle_webhook(webhook_data: WebhookPayload):
    payload = json.loads(webhook_data.resource["payload"])
    # Now payload is your original list of dictionaries
    ...
I recommend the first approach (modifying the webhook template) as it's simpler and maintains better compatibility with Prefect's webhook validation. Let me know if you need help implementing either solution!
n
๐Ÿคจ skeptical about the double
tojson
suggestion
what's the flow signature?
m
@Nate the double tojson actually worked. this is the flow signature fwiw
Copy code
@flow()
def my_flow(payload: str):
i previously tried changing the type to dict but got an empty dictionary when i did that
n
oh nice! yea that doc i shared shows how to indicate you want the native type, i have an example somewhere i'll try and find
๐Ÿ‘ 1