webhook firing off without actual change occuring

I have a webhook setup that is captured in zapier to start an automation on a project board

<Asana /webhooks/1202824082522084>
List of 1
 $ data:List of 10
  ..$ gid                 : chr "1202824082522084"
  ..$ active              : logi TRUE
  ..$ created_at          : chr "2022-08-18T19:53:01.473Z"
  ..$ last_failure_at     : NULL
  ..$ last_failure_content: chr ""
  ..$ last_success_at     : chr "2022-08-21T07:46:09.893Z"
  ..$ resource            :List of 3
  .. ..$ gid          : chr "1202785046413617"
  .. ..$ name         : chr "The Board Name"
  .. ..$ resource_type: chr "project"
  ..$ resource_type       : chr "webhook"
  ..$ target              : chr "https://hooks.zapier.com/hooks/catch/13165208/xxxxx/"
  ..$ filters             :'data.frame':	1 obs. of  4 variables:
  .. ..$ resource_type   : chr "story"
  .. ..$ resource_subtype: chr "section_changed"
  .. ..$ action          : chr "added"
  .. ..$ fields          : logi NA

I have noticed that it is triggering zapier even when nothing changes on the resource project

I am not sure what error I could even put in since zapier is ingesting the webhook. All I can see is that the output is empty

I was having trouble anyways with phantom task_id’s sent by the api through the webhook see this issue

so i put in a check step to see that the task_id exists on the project board

import requests
import re

ACCESS_TOKEN = input_data['ACCESS_TOKEN']
API_URL = "https://app.asana.com/api/1.0"
headers = {"Authorization": f"Bearer {ACCESS_TOKEN}"}
url = f"{API_URL}/projects/{input_data['project_id']}/tasks"

r = requests.get(url, headers=headers)
tasks = r.json()["data"]

i = 0
for x in tasks:
  i = i + int(x['gid']==input_data['task_id'])

found = bool(i)
output = {'found': found}

This code is breaking because input_data['task_id'] is empty from the webhook initial step and returns

Traceback (most recent call last):
    File "<string>", line 22, in the_function
KeyError: 'task_id'

My main concern is that nothing is actually happening on the board and the webhook is being triggered. I can always create logic around it to stop the error, but I would want to understand if I set something up wrong first.

The input_data['task_id'] isnt actually empty it is returning:

input:
ACCESS_TOKEN:	xxxx
task_id:	{{165136605__events[]parent__gid}}
project_id:	1202785046413617

which isn’t what I am expecting to return as the task_id value or object type in this context

This is what a successful webhook output would look like

events:
1:
user:
  gid:	1200327866514063
  resource_type:	user
created_at:	2022-08-20T18:05:29.451Z
action:	added
resource:
  gid:	1202834414038594
  resource_type:	story
  resource_subtype:	section_changed
parent:
  gid:	1202815936862786
  resource_type:	task
  resource_subtype:	default_task
Fields with no value:
querystring

After tracking the behavior for 24 hrs it looks like the webhook is triggered every ~7.5 hrs even though the resource project is idle.

Hi @Yoni_Sidi,

I’m sure these are the Webhook Heartbeat Events.

That makes sense.

Thanks for that reference!

I already put in a conditional to catch that event, now I can rest easy that it is part of the natural process.

1 Like