Custom Code Action Retry Mechanism Not Triggering

I am reaching out to seek your assistance with an issue I am experiencing with the retry mechanism for my custom code action in HubSpot workflows. Despite following the documented guidelines for raising exceptions to trigger retries, it appears that the retry mechanism is not being activated as expected.

Here are the details of my current implementation:

  • API Key Initialization: I am initializing the HubSpot client using an API key retrieved from environment variables.
  • Simulated API Call: I am making a simulated API request to https://example.com/test-endpoint to test the retry mechanism.
  • Exception Handling: I am raising exceptions for HTTP errors and request-related issues to signal HubSpot to retry the action.

Below is the core part of my code:

import requests
import os
from hubspot import HubSpot
from requests.exceptions import HTTPError

def main(event):
 api_key = os.getenv('api_key')
 if not api_key:
 raise ValueError("api_key is missing in environment variables")

 hubspot = HubSpot(access_token=api_key)
 print(hubspot)

 url = "https://example.com/test-endpoint"

 try:
 response = requests.get(url)
 response.raise_for_status()

 return {
 "outputFields": {
 "message": "Request was successful."
 }
 }

 except HTTPError as e:
 print(f"HTTP error occurred and will trigger retry: {e}")
 raise

 except requests.exceptions.RequestException as e:
 print(f"Request error occurred: {e}")
 raise

 except Exception as e:
 print(f"An error occurred: {e}")
 raise
​

Despite the exceptions being raised correctly, the retry mechanism does not seem to be engaged by HubSpot. I am seeing error messages such as:

HTTP error occurred and will trigger retry: 500 Server Error: Internal Server Error for url: https://example.com/test-endpoint
LAMBDA_WARNING: Unhandled exception.
​

provide guidance on what might be missing or incorrectly configured to ensure the retry mechanism works as intended?

Thank you in advance for your assistance.

Hi, @MoneebAmin :waving_hand: Thanks for including your details. We’re you able to make any progress with your issue? — Jaycee

Hi @MoneebAmin,

Any luck resolving this? I’m facing the same issue. According to the documentation, simply raising an exception should prompt HubSpot to retry after a few hours, but that doesn’t seem to be working as expected. I’m a bit confused about this.