Hi, I’m new to using the custom code function and when I test the default code block it gives when selecting python as the language it fails, but when I test with the custom JS block it works.
The JS code is here:
exports.main = async (event, callback) => {
/*****
Use inputs to get data from any action in your workflow and use it in your code instead of having to use the HubSpot API.
*****/
const email = event.inputFields[‘email’];
/*****
Use the callback function to output data that can be used in later actions in your workflow.
*****/
callback({
outputFields: {
email: email
}
});
}
The python code is here:
def main(event):
email = event[“inputFields”][“email”]
# Return the output data that can be used in later actions in your workflow.
return {
“outputFields”: {
“email”: email
}
}
The python code fails with this message:
LAMBDA_WARNING: Unhandled exception. The most likely cause is an issue in the function code. However, in rare cases, a Lambda runtime update can cause unexpected function behavior. For functions using managed runtimes, runtime updates can be triggered by a function change, or can be applied automatically. To determine if the runtime has been updated, check the runtime version in the INIT_START log entry. If this error correlates with a change in the runtime version, you may be able to mitigate this error by temporarily rolling back to the previous runtime version. For more information, see https://docs.aws.amazon.com/lambda/latest/dg/runtimes-update.html
[ERROR] KeyError: 'email'
Traceback (most recent call last):
File "/var/task/hubspotHandler.py", line 6, in hubspot_handler
return file.main(event)
File "/var/task/file.py", line 3, in main
email = event["inputFields"]["email"]
Memory: 31/128 MB
Runtime: 3.93 ms