temporalio / temporalio/sdk-java

External workflow signal from a workflow code throws incorrect exceptions

Open
#1,374 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Java
Stars
433
Forks
249
Avg merge
5d 6h
Merged PRs (30d)
26

Description

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: https://github.com/temporalio/sdk-java/blob/37a0e463fae2312882b5c946f423a0dbf85f9666/temporal-sdk/src/main/java/io/temporal/internal/statemachines/SignalExternalStateMachine.java#L152

Another alternative exception to consider here may be WorkflowNotFoundException

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in temporal-sdk/src/main/java/io/temporal/internal/statemachines/SignalExternalStateMachine.java at the TODO around line 152, then inspect SignalExternalWorkflowException and WorkflowNotFoundException. Trace the external signal failure path and determine which exception should represent a missing target instead of ApplicationFailure. Done means the signal path creates and propagates the selected exception consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
distributed-systems
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.