SuccessAction type field incorrectly deserialized in onSuccess list when multiple actions present
Environment
- Library: openapi-workflow-parser
- Version: 0.0.4
- YAML Parser: Jackson with YAMLFactory
- Issue: Polymorphic deserialization of heterogeneous action lists fails
Description
When deserializing an Arazzo YAML file with multiple success actions of different types in the onSuccess list, Jackson incorrectly assigns the first action's type value to subsequent actions in the list.
Reproducible Example
YAML Input:
arazzo: 1.0.0
info:
title: Test End Action
version: 1.0.0
sourceDescriptions:
- name: test
url: https://petstore3.swagger.io/api/v3/openapi.json
type: openapi
workflows:
- workflowId: testWorkflow
summary: Test Workflow
steps:
- stepId: testStep
operationId: test.addPet
successCriteria:
- condition: "$statusCode == 200"
onSuccess:
- name: gotoAction
type: goto
workflowId: targetWorkflow
- name: endAction
type: end
Expected Behavior:
- First action:
type="goto", workflowId="targetWorkflow"
- Second action:
type="end", workflowId=null
Actual Behavior (BUG):
- First action:
type="goto", workflowId="targetWorkflow"
- Second action:
type="goto" (should be "end")
workflowId=null (inherits from first action)
Error Generated:
[ERROR] [PARSE] Step testStep SuccessAction must define either workflowId or stepId
Validation at line 648 in OpenAPIWorkflowValidator.java fails because:
successAction.getType() returns "goto" (incorrect)
successAction.getStepId() is null
successAction.getWorkflowId() is null
- Condition:
if (targetWorkflowId == null && targetStepId == null) evaluates to TRUE
Root Cause
The SuccessAction and FailureAction classes lack Jackson @JsonTypeInfo annotations for polymorphic type handling. When Jackson deserializes a YAML list containing heterogeneous action objects without explicit type discriminators, it reuses the first object's field values for subsequent objects in the list.
Problem Code Location:
File: src/main/java/com/apiflows/model/SuccessAction.java
Current:
public class SuccessAction extends Action {
// NO @JsonTypeInfo annotation
}
Should be:
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCED, defaultImpl = SuccessAction.class)
public class SuccessAction extends Action {
// ...
}
Impact
Solution
Add Jackson polymorphic type handling annotations to:
SuccessAction class
FailureAction class
- Consider adding
@JsonAnySetter or @JsonDeserialize for better control
Example fix:
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCED)
@JsonSubTypes({
@JsonSubTypes.Type(value = SuccessAction.class, name = "end"),
@JsonSubTypes.Type(value = SuccessAction.class, name = "goto")
})
public class SuccessAction extends Action {
// existing code
}
Or use property-based discrimination:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = SuccessAction.class)
public class SuccessAction extends Action {
// existing code
}
SuccessAction type field incorrectly deserialized in onSuccess list when multiple actions present
Environment
Description
When deserializing an Arazzo YAML file with multiple success actions of different types in the
onSuccesslist, Jackson incorrectly assigns the first action'stypevalue to subsequent actions in the list.Reproducible Example
YAML Input:
Expected Behavior:
type="goto",workflowId="targetWorkflow"type="end",workflowId=nullActual Behavior (BUG):
type="goto",workflowId="targetWorkflow"type="goto"(should be "end")workflowId=null(inherits from first action)Error Generated:
Validation at line 648 in
OpenAPIWorkflowValidator.javafails because:successAction.getType()returns "goto" (incorrect)successAction.getStepId()is nullsuccessAction.getWorkflowId()is nullif (targetWorkflowId == null && targetStepId == null)evaluates to TRUERoot Cause
The
SuccessActionandFailureActionclasses lack Jackson@JsonTypeInfoannotations for polymorphic type handling. When Jackson deserializes a YAML list containing heterogeneous action objects without explicit type discriminators, it reuses the first object's field values for subsequent objects in the list.Problem Code Location:
File:
src/main/java/com/apiflows/model/SuccessAction.javaCurrent:
Should be:
Impact
Solution
Add Jackson polymorphic type handling annotations to:
SuccessActionclassFailureActionclass@JsonAnySetteror@JsonDeserializefor better controlExample fix:
Or use property-based discrimination: