Skip to content

Empty fields Marshaled as "field":null #171

@spolti

Description

@spolti

What happened:
When Marshaling a workflow that contains switch states, if the dataCondition[x].End is empty it will be marsheled as "null", the same happens with eventConditions or defaultCondition, example:

{
  "id":"test",
  "version":"",
  "start":{
    "stateName":"ChooseOnLanguage"
  },
  "specVersion":"1.0",
  "expressionLang":"jq",
  "states":[
    {
      "name":"ChooseOnLanguage",
      "type":"switch",
      "defaultCondition":{
        "transition":{
          "nextState":"GreetInEnglish"
        }
      },
      "eventConditions":null,
      "dataConditions":[
        {
          "condition":"${ .language == \"English\" }",
          "end":null,
          "transition":{
            "nextState":"GreetInEnglish"
          }
        },

What you expected to happen:
The output json object should not contain the "null" fields.

How to reproduce it:
Cann the json.Marshal method in a workflow like this example:

id: helloworld
version: '1.0.0'
specVersion: '0.8'
name: WorkflowSwitchStateDataConditions with wrong field name
description: Inject Hello World
start: Hello State
states:
- name: Hello State
  type: switch
  dataCondition:
  - condition: ${ true }
    transition:
      nextState: HandleApprovedVisa
  - condition: ${ false }
    transition:
      nextState: HandleRejectedVisa
  defaultCondition:
    transition:
      nextState: HandleApprovedVisa
- name: HandleApprovedVisa
  type: operation
  actions:
  - subFlowRef:
      workflowId: handleApprovedVisaWorkflowID
  end:
    terminate: true
- name: HandleRejectedVisa
  type: operation
  actions:
  - subFlowRef:
      workflowId: handleRejectedVisaWorkflowID
  end:
    terminate: true
- name: HandleNoVisaDecision
  type: operation
  actions:
  - subFlowRef:
      workflowId: handleNoVisaDecisionWorkflowId
  end:
    terminate: true

Anything else we need to know?:

Environment:

  • Specification version used:
  • Go version:

Metadata

Metadata

Assignees

Labels

bug 🐛Something isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions