Workflows: getting unknown error when making a request to HubSpot API. "at null.search (file:///tmp/ee/c_N2fM6el/index.mjs:292:9)"

Hi,

I have created a script locally on my computer. The script works but when I copy it over to workflow I get the following error:

at null.search (file:///tmp/ee/c_N2fM6el/index.mjs:292:9)
    at Object.run (file:///tmp/ee/c_N2fM6el/index.mjs:405:37)
    at process.processTicksAndRejections (internal/process/task_queues.js:95:5)
    at global.executeComponent (/var/task/launch_worker.js:154:22)
    at MessagePort.messageHandler (/var/task/launch_worker.js:620:35)

Other functions in the workflow work except for one.

Any idea what this error means?

Thanks,
Lar

Hi @lharney, hope you’re doing well.

Would it be possible for you to share the script contents?

Thanks,
Pierce

Hi @pierce,

What email will I share it to?
Is there a share option on the workflow(I can’t find it) or will I just email you the code?

Thanks,
Lar

Hi @lharney ,

If sharing the code here isn’t an option, you can choose to enable the Share with Support toggle in your workflow’s settings.

The other way is to share the workflow with my account directly: pierce@pipedream.com.

Hi @pierce,

I enabled share with support. Is there anything further I need to do or do you have access?

Thanks,
Lar

Hi @lharney ,

I believe I have found the workflow, thanks for sharing. I believe the action is titled hubspot, and the workflow is Appointments.

But I’m seeing the most recent logs show successful runs - are you seeing the same now?

If not, could you share a specific timestamp of an example event with this error?

Hi @pierce,

Correct, that’s the one.
The error appears when the search function is called.
It works when ran locally on a script but displays an error when ran on the workflow.

Thanks,
Lar

Hi @lharney ,

Took me a minute to figure out that you were logging a caught error.

The axios response data can be pretty long, but searching for status in your error message found that the API you’re calling is giving a 400 as a response:

CleanShot 2022-03-02 at 09.14.33@2x

When I catch axios errors, I like to trim to console.log the errors only:

try {
  await axios.post(somewhere);
} catch (e) {
  console.error(e.response.statusCode, e.response.data);
}

This caught error explains why the event log is saying Success even though the API you’re querying is rejecting your requests.

I hope this helps.

1 Like

Hi @pierce,

Thanks for taking the time to help. I resolved the error thanks to your help.

The issue was that I did not declare the response variable as a variable.

I had "response = " rather than “var response =”.

This did not throw an error locally but when I removed the try catch on pipedream the error response was clear.

Thanks again,
Lar

1 Like