How to Terminate a Workflow Successfully and Mark Its State as Failed in Pipedream?

This topic was automatically generated from Slack. You can find the original thread here.

Is there a way to terminate a workflow successfully, but mark it’s state as failed?

In some cases, we’re handling the error reporting ourselves with custom Slack notifications, so we don’t need the additional failed workflow notification from Pipedream.

But in the workflow inspector, it would be nice to see the state of those workflows as failed/terminated with errors (otherwise, they are hard to find).

It’s an interesting use case and I hear you completely re: wanting to flag it as an error.

The best way right now would be to create a custom error workflow. In each of your original workflows, you’d throw an error:

throw new Error("error")

Errors that you want to appear with the error status (but not notify you) could be of the form InternalError* (for example). Since you have access to the error name + stack in the custom error workflow, you could exit early on these special errors so you don’t send yourself a Slack notification.

Let me know if that works.

Well I guess the issue is that right now we are using the integrated Slack notifications, so we receive them for everything:

image.png

But yeah, if we handled the errors with our own custom workflow, we could filter some of them out. :+1:

yeah in this case, you could disable that setting and just reproduce the Slack message in your custom error workflow. I can share the current Slack block code that’s used in that error notification if that would be helpful!

All good, we’ll figure it out! :+1:

But thanks for the input, we’ll play around with that idea! :pray:

It might actually help to improve some of our flow control code/steps as well. :ok_hand:

Couldn’t you also throw and disable error handling for those workflows?

Then you would receive no errors for the workflow, but I think the idea is you want to get notified of some errors, just not the expected errors?

oh yeah I misread your original request , Danny’s suggestion will do it since you’re already handling errors within the workflow itself

So if you visit your workflow’s Settings and uncheck the Notify me on errors toggle. You’ll still see them reported as errors in the UI, you’ll get them in Slack since you’re error-handling in code, and they won’t trigger the global Slack notifier

We’re only handling errors we’re expecting (from third party APIs), so it would still be good to be notified of the other unexpected ones (in case a step fails for some reason), as you mentioned. :+1:

We’ll stick to the original idea. It’ll allow us to devise error handling in a generic way, which will reduce repetition in some of our workflows. :ok_hand:

Although that may mean we need to disable error handling for those workflows, so that we don’t get notified twice (once from the workflow itself and once from the error handling workflow). :thinking_face:

But if generic error handling works well… we’ll just disable the default Slack notifications entirely.

Ok cool that makes sense. Yeah the global error notifier is pretty cool… we tried to modernize the dead letter queue! If you have any feedback on that implementation / any suggested improvements definitely let us know