Skip to content

External workflow signal from a workflow code throws incorrect exceptions #1374

@Spikhalskiy

Description

@Spikhalskiy

Actual Behavior

fun signalWorkflow(workflowId: String, signalName: String, vararg args: Any) {
        try {
            Workflow.newUntypedExternalWorkflowStub(workflowId).signal(signalName, args)
        } catch (ex: ApplicationFailure) {
            if (ex.type == "SIGNAL_EXTERNAL_WORKFLOW_EXECUTION_FAILED_CAUSE_EXTERNAL_WORKFLOW_EXECUTION_NOT_FOUND") {
                logger.info {
                    it.message("Workflow not found while attempting to send signal to it.")
                        .value("workflowId", workflowId).value("signal", signalName)
                }
            }
        }
    }

The code above shouldn't work and ApplicationFailure is an incorrect exception to be thrown here.

Additional context

There is already an exception for this situation: SignalExternalWorkflowException that is currently not created anywhere.

There is also a todo to implement exactly this that never was done:

Another alternative exception to consider here may be WorkflowNotFoundException

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions