Question

Getting a key error when a property coming in through the zap has null value

  • 7 August 2023
  • 2 replies
  • 109 views

Userlevel 1

To set some context: We have setup a webhook that fetches property values from Hubspot CRM and what I’m trying to do is receive those values, perform some operations on them in the ‘Run Python in Code by Zapier’ block and send that data to Notion via an API call!
 

 

Failed to run your Python code
Your code had an error! Traceback (most recent call last): File "<string>", line 83, in the_function KeyError: 'readMe'

 


I have been getting the above error while trying to parse a custom property called Plugin ReadMe URL’s value into an input key called readMe. This works absolutely fine when that property has a value coming in but fails when it doesn’t, as is the case in the above screenshot. I have noted the same behaviour for other parameters as well; in that it fails when the property has a null value.

Coming back to the error for this key; per my use case, it may or may not have values and when it doesn’t I would like to send a null value to Notion in my API call.

Can you please help me with a fix for this? Any help is appreciated :)

Thanks in advance!


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

2 replies

Userlevel 7
Badge +14

Hi @Sihaan 

Good question.

Try asking ChatGPT to optimize the code to handle that use case logic of nulls.

Userlevel 1

Hey thanks for the response!

I managed to fix it by using input.get("keyName") instead of input_data["keyName"].