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.0info:
title: Test End Actionversion: 1.0.0sourceDescriptions:
- name: testurl: https://petstore3.swagger.io/api/v3/openapi.jsontype: openapiworkflows:
- workflowId: testWorkflowsummary: Test Workflowsteps:
- stepId: testStepoperationId: test.addPetsuccessCriteria:
- condition: "$statusCode == 200"onSuccess:
- name: gotoActiontype: gotoworkflowId: targetWorkflow
- name: endActiontype: 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 nullsuccessAction.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:
publicclassSuccessActionextendsAction {
// NO @JsonTypeInfo annotation
}Should be:
@JsonTypeInfo(use = JsonTypeInfo.Id.DEDUCED, defaultImpl = SuccessAction.class)
publicclassSuccessActionextendsAction {
// ...
}Impact
Solution
Add Jackson polymorphic type handling annotations to:
SuccessAction classFailureAction 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")
})
publicclassSuccessActionextendsAction {
// existing code
}Or use property-based discrimination:
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = SuccessAction.class)
publicclassSuccessActionextendsAction {
// 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: