- Notifications
You must be signed in to change notification settings - Fork50
Open
Labels
Description
What happened:
Given the following builder:
publicclassWorkFlowBuilder {publicWorkflowbuildWorkFlow()throwsJsonProcessingException {ObjectMappermapper =newObjectMapper();JsonNodesendOrderArgs =mapper.readTree(""" { "supplier-id": "1", "content": ".orderId", "locator": ".reference" } """);JsonNodeprintMessageArgs =mapper.readTree(""" { "message": "\\"Order received:\\" + .orderId", "locator": ".reference" } """);// Define Function DefinitionsFunctionDefinitionsendOrderFunction =newFunctionDefinition() .withName("sendOrder") .withOperation("specs/sendOrderOpenApi.yaml#sendOrder") .withType(FunctionDefinition.Type.CUSTOM);FunctionDefinitionprintMessageFunction =newFunctionDefinition() .withName("printMessage") .withOperation("specs/printMessage.yaml#printMessage") .withType(FunctionDefinition.Type.CUSTOM);// Define ActionsActionsendOrderAction =newAction() .withName("sendOrder") .withFunctionRef(newio.serverlessworkflow.api.functions.FunctionRef() .withRefName("sendOrder") .withArguments(sendOrderArgs) .withInvoke(FunctionRef.Invoke.SYNC)) .withRetryRef("defaultRetry") .withRetryableErrors(List.of("Internal Server error","Bad Gateway","Service Unavailable","Gateway timeout","Insufficient storage","Locked" )) .withNonRetryableErrors(List.of());ActionprintMessageAction =newAction() .withName("printMessage") .withFunctionRef(newio.serverlessworkflow.api.functions.FunctionRef() .withRefName("printMessage") .withArguments(printMessageArgs) .withInvoke(FunctionRef.Invoke.SYNC)) .withRetryRef("defaultRetry") .withRetryableErrors(sendOrderAction.getRetryableErrors()) .withNonRetryableErrors(List.of());// Define StateOperationStateorderReceivedState =newOperationState() .withName("Order Received") .withType(DefaultState.Type.OPERATION) .withActionMode(OperationState.ActionMode.SEQUENTIAL) .withActions(List.of(sendOrderAction,printMessageAction)) .withUsedForCompensation(false) .withEnd(newEnd().withTerminate(true).withProduceEvents(List.of()).withCompensate(false)) .withOnErrors(List.of());Functionsfunctions =newFunctions();functions.setFunctionDefs(List.of(sendOrderFunction,printMessageFunction));Errorserrors =newErrors();errors.setRefValue("specs/errors.yaml");// Build WorkflowreturnnewWorkflow() .withId("order") .withName("Order Workflow") .withDescription("Order Workflow Sample") .withVersion("1.0") .withStart(newStart().withStateName("Order Received")) .withExpressionLang("jq") .withKeepActive(false) .withAutoRetries(false) .withFunctions(functions) .withErrors(errors) .withStates(List.of(orderReceivedState)) .withExtensions(List.of()); }}
Would marshal the functions and errors as:
functions:refValue:nullfunctionDefs: -name:"sendOrder"operation:"specs/sendOrderOpenApi.yaml#sendOrder"type:"custom" -name:"printMessage"operation:"specs/printMessage.yaml#printMessage"type:"custom"errors:refValue:"specs/errors.yaml"errorDefs:null
There's a clear problem with how the marshallers processanyOf
attributes within the JSON Schema.
What you expected to happen:
The output should be:
functions: -name:"sendOrder"operation:"specs/sendOrderOpenApi.yaml#sendOrder"type:"custom" -name:"printMessage"operation:"specs/printMessage.yaml#printMessage"type:"custom"errors: -"specs/errors.yaml"
Null objects should also be ignored.
How to reproduce it:
Run the givenWorkflowBuilder
Anything else we need to know?:
Whole output of the following builder:
id:"order"name:"Order Workflow"description:"Order Workflow Sample"version:"1.0"annotations:[]start:stateName:"Order Received"expressionLang:"jq"keepActive:falseautoRetries:falsefunctions:refValue:nullfunctionDefs: -name:"sendOrder"operation:"specs/sendOrderOpenApi.yaml#sendOrder"type:"custom" -name:"printMessage"operation:"specs/printMessage.yaml#printMessage"type:"custom"errors:refValue:"specs/errors.yaml"errorDefs:nullstates: -actionMode:"sequential"actions: -name:"sendOrder"functionRef:refName:"sendOrder"arguments:supplier-id:"1"content:".orderId"locator:".reference"invoke:"sync"retryRef:"defaultRetry"nonRetryableErrors:[]retryableErrors: -"Internal Server error" -"Bad Gateway" -"Service Unavailable" -"Gateway timeout" -"Insufficient storage" -"Locked" -name:"printMessage"functionRef:refName:"printMessage"arguments:message:"\"Order received:\" + .orderId"locator:".reference"invoke:"sync"retryRef:"defaultRetry"nonRetryableErrors:[]retryableErrors: -"Internal Server error" -"Bad Gateway" -"Service Unavailable" -"Gateway timeout" -"Insufficient storage" -"Locked"usedForCompensation:falsename:"Order Received"type:"operation"end:terminate:trueproduceEvents:[]compensate:falseonErrors:[]extensions:[]
Environment:
- Specification version used: 0.8