Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty fields Marshaled as "field":null #171

Closed
spolti opened this issue May 3, 2023 · 0 comments · Fixed by #172
Closed

Empty fields Marshaled as "field":null #171

spolti opened this issue May 3, 2023 · 0 comments · Fixed by #172
Assignees
Labels
bug 🐛 Something isn't working

Comments

@spolti
Copy link
Member

spolti commented May 3, 2023

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:
@spolti spolti added the bug 🐛 Something isn't working label May 3, 2023
@spolti spolti self-assigned this May 3, 2023
spolti added a commit to spolti/sdk-go that referenced this issue May 3, 2023
fixes serverlessworkflow#171

Signed-off-by: Spolti <filippespolti@gmail.com>
spolti added a commit to spolti/sdk-go that referenced this issue May 3, 2023
fixes serverlessworkflow#171

Signed-off-by: Spolti <filippespolti@gmail.com>
ricardozanini pushed a commit that referenced this issue May 4, 2023
fixes #171

Signed-off-by: Spolti <filippespolti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant