workflowContext.currentRun.error.message always null

I'm trying to setup an error handling to post to slack on error. For some reason, the workflowContext.currentRun.error.message.ToString() is always showing as null. If I don't use .ToString(), then the Slack message errors with invalid_blocks_format.

2 Likes

Hi @jonnilundy, welcome to the forum! :wave:

Could we try adding a JS block as the error handler that returns workflowContext.currentRun.error.message to make sure the message is what we're expecting? Then, have the Slack block reference whats returned by the JS block instead.

1 Like

Only getting a null response

Let's try with a JS block:
Screenshot 2024-05-07 at 5.34.38 PM

Works in a JS block.

This is what I meant:

Note: My Slack integration has different parameters, use yours.


When we run the workflow and there is an error, we should be able to see the value of code1.data in the logs.

2 Likes

Interesting. Is the desired flow? Seems a bit strange to add a block just to return a variable that already exists.

Thanks for the workaround!

Tried this in production but its not working.

This is definitely not the desired flow, it was mostly to confirm the output of workflowContext.currentRun.error.message before we send it to the Slack query, but I'm glad we got it to work in the editor so far. Could you confirm the edits we made were deployed before testing in production?

Just confirmed that it is indeed deployed.

Could you share the logs from the workflow?

Mo 05/20/2024 11:31:25	Starting run for workflow: 92154227-900e-4f25-b1f9-40685227e995 in environment production
Mo 05/20/2024 11:31:25	Workflow Run Id: 374129c9-18cb-4bff-b203-1f6dbe9250a3
Mo 05/20/2024 11:31:25	Workflow Trigger Id: 803df13c-c54b-4308-8021-36174f25d5ee
Mo 05/20/2024 11:31:25	--- Running query: startTrigger ---
Mo 05/20/2024 11:31:25	--- Successfully finished running query: startTrigger ---
Mo 05/20/2024 11:31:25	--- Running query: tld ---
Mo 05/20/2024 11:31:25	--- Successfully finished running query: tld ---
Mo 05/20/2024 11:31:25	--- Running query: dnsData ---
Mo 05/20/2024 11:31:26	--- Successfully finished running query: dnsData ---
Mo 05/20/2024 11:31:26	--- Running query: prettyNameserver ---
Mo 05/20/2024 11:31:26	--- Successfully finished running query: prettyNameserver ---
Mo 05/20/2024 11:31:26	--- Running query: isServerReachable ---
Mo 05/20/2024 11:31:27	--- Successfully finished running query: isServerReachable ---
Mo 05/20/2024 11:31:27	--- Running query: mxLookup ---
Mo 05/20/2024 11:31:27	--- Successfully finished running query: mxLookup ---
Mo 05/20/2024 11:31:27	--- Running query: getTeam ---
Mo 05/20/2024 11:31:27	--- Successfully finished running query: getTeam ---
Mo 05/20/2024 11:31:27	--- Running query: saveDomainToDB ---
Mo 05/20/2024 11:31:28	--- Successfully finished running query: saveDomainToDB ---
Mo 05/20/2024 11:31:28	--- Running query: triggerSperta ---
Mo 05/20/2024 11:31:28	Error evaluating triggerSperta: {"code":3,"message":"Invalid input to Timestamp feature `dns_registrar_expiring_at`: `map[]`.","details":[]}
Mo 05/20/2024 11:31:28	--- Failed running query: triggerSperta ---
Mo 05/20/2024 11:31:28	--- Hit failure, skipping queries: createCase, selectRuleOutputs, createCaseDecisions, actionBranch, blockHard, blockSoft, review, successResponse ---
Mo 05/20/2024 11:31:29	--- Running query: error ---
Mo 05/20/2024 11:31:29	--- Successfully finished running query: error ---
Mo 05/20/2024 11:31:29	--- Running query: errorNotification ---
Mo 05/20/2024 11:31:29	--- Successfully finished running query: errorNotification ---
Mo 05/20/2024 11:31:31	--- Successfully finished running the workflow ---

This run sent this message to slack:

I'm trying to reproduce this bug without success. So far I have:

  1. A SQL query with a syntax error to purposely hit the global error handler (JS block).
  2. A Slack Resource that sends the message to a channel, it references the data of the JS query.

Here is the workflow:

With this setup, I can see the error message in the Channel.

2 Likes

Thanks for trying to reproduce, Paulo. This is so weird... I'm not sure what else to try.



I know you tried this already but let's change the name of the JS query to something else than "error". It may be a reserved keyword. Try something like "errorBlock" and update the Slack resource comment field

I don't have the same version you are using for the Slack API but I wonder if "comment" is the right key. Could we try setting comment to "Hello World" and see if you get that on the channel?

1 Like

I tried with renaming error to errorBlock but still the same output.

The slack comment is actually just a variable. Here is the full request:

I tried changing this to the default slack message send block, but same results:


On this object, what are {{action}} & {{comment}} referencing to?

These are just variables (strings) that to populate the slack message I use within workflows.

I see, you are importing the query from the QL. With the default Slack message send block, when you set the text to a hard coded value like "Hello World:"

Do you get the text on Slack?