[Fix #1317] Setting stack trace to details and filling instance#1318
[Fix #1317] Setting stack trace to details and filling instance#1318fjtirado merged 1 commit intoserverlessworkflow:mainfrom
Conversation
There was a problem hiding this comment.
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
WorkflowPositioninto error mapping forTaskFailedEventto populateinstancewithposition.jsonPointer()when available. - Correct non-
WorkflowExceptionmapping to settitleto the exception message anddetailto the stack trace.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
47c8626 to
b0122a4
Compare
There was a problem hiding this comment.
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
WorkflowErrorrecord component was renamed todetail, but the nestedBuilderAPI still usesdetails(field name + setter). This leaves two different names for the same concept (record accessor isdetail()/ JSON field isdetail, while builder usesdetails(...)), which is easy to misuse and makes the rename feel incomplete. Consider renaming the builder field/setter todetail, and (if you need backwards compatibility) keepingdetails(...)as a deprecated alias that forwards todetail(...).
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, andinstanceshould be position/null), but there is no regression test covering the non-WorkflowExceptionpath used byWorkflowError.error(…Event)(i.e., when the failure is a plain runtime exception). Add a test that triggers a workflow fault from a non-WorkflowExceptioncause and assert that the publishedworkflow.faultedCloudEvent haserror.detailcontaining the stack trace anderror.instanceset 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.
1a96898 to
6665392
Compare
There was a problem hiding this comment.
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>
Fix #1317