Skip to content

[Fix #1317] Setting stack trace to details and filling instance#1318

Merged
fjtirado merged 1 commit intoserverlessworkflow:mainfrom
fjtirado:Fix_#1317
Apr 16, 2026
Merged

[Fix #1317] Setting stack trace to details and filling instance#1318
fjtirado merged 1 commit intoserverlessworkflow:mainfrom
fjtirado:Fix_#1317

Conversation

@fjtirado
Copy link
Copy Markdown
Collaborator

Fix #1317

Copilot AI review requested due to automatic review settings April 15, 2026 12:52
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes issue #1317 by correcting how fault lifecycle CloudEvent error fields are populated when the failure is not represented by a WorkflowError (i.e., not a WorkflowException), ensuring stack traces go to detail and the task location goes to instance.

Changes:

  • Pass WorkflowPosition into error mapping for TaskFailedEvent to populate instance with position.jsonPointer() when available.
  • Correct non-WorkflowException mapping to set title to the exception message and detail to the stack trace.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings April 15, 2026 13:36
@fjtirado fjtirado force-pushed the Fix_#1317 branch 2 times, most recently from 47c8626 to b0122a4 Compare April 15, 2026 13:37
Comment thread impl/test/src/test/resources/workflows-samples/try-catch-error-variable.yaml Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

impl/core/src/main/java/io/serverlessworkflow/impl/WorkflowError.java:28

  • WorkflowError record component was renamed to detail, but the nested Builder API still uses details (field name + setter). This leaves two different names for the same concept (record accessor is detail() / JSON field is detail, while builder uses details(...)), which is easy to misuse and makes the rename feel incomplete. Consider renaming the builder field/setter to detail, and (if you need backwards compatibility) keeping details(...) as a deprecated alias that forwards to detail(...).
public record WorkflowError(String type, int status, String instance, String title, String detail) {

  public static Builder error(String type, int status) {
    return new Builder(type, status);
  }

impl/test/src/test/java/io/serverlessworkflow/impl/test/LifeCycleEventsTest.java:235

  • The change is intended to fix #1317 (stack trace should go to detail, and instance should be position/null), but there is no regression test covering the non-WorkflowException path used by WorkflowError.error(…Event) (i.e., when the failure is a plain runtime exception). Add a test that triggers a workflow fault from a non-WorkflowException cause and assert that the published workflow.faulted CloudEvent has error.detail containing the stack trace and error.instance set to the task position when available (or null when not available).
  @Test
  void testError() throws IOException {
    Workflow workflow =
        WorkflowReader.readWorkflowFromClasspath("workflows-samples/raise-inline.yaml");
    assertThat(
            catchThrowableOfType(
                CompletionException.class,
                () -> appl.workflowDefinition(workflow).instance(Map.of()).start().join()))
        .isNotNull();
    WorkflowError error =
        assertPojoInCE("io.serverlessworkflow.workflow.faulted.v1", WorkflowFailedCEData.class)
            .error();
    assertThat(error.type()).isEqualTo("https://serverlessworkflow.io/errors/not-implemented");
    assertThat(error.title()).isEqualTo("Not Implemented");
    assertThat(error.status()).isEqualTo(500);
    assertThat(error.detail()).contains("raise-not-implemented");
  }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread impl/test/src/test/resources/workflows-samples/try-catch-error-variable.yaml Outdated
@fjtirado fjtirado force-pushed the Fix_#1317 branch 2 times, most recently from 1a96898 to 6665392 Compare April 15, 2026 14:02
Copilot AI review requested due to automatic review settings April 15, 2026 14:02
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

…ing instance

Signed-off-by: fjtirado <ftirados@redhat.com>
@fjtirado fjtirado merged commit 6e6557c into serverlessworkflow:main Apr 16, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong field usage on FAult lifecycle cloud event

3 participants