Skip to content

SuccessAction type field incorrectly deserialized in onSuccess list when multiple actions present #79

Description

@vishaltripathi24

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:

  1. SuccessAction class
  2. FailureAction class
  3. 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
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions