Skip to content

fix: workflow BSON serialization - array markers, parameter binding, outcomes #3

@engalar

Description

@engalar

Summary

Commit 3405dd7 fixes 13 CE errors in workflow BSON serialization, building on a6774ad.

Changes

1. BSON Array Markers (writer_workflow.go)

Fixed incorrect int32(3)int32(2) for:

  • BoundaryEvents (all activity types)
  • ParameterMappings (CallMicroflowTask, CallWorkflowActivity)
  • Parameters (StringTemplate)

Root cause: Not all PartListProperty arrays use the same marker. Activities/Outcomes use int32(3), while BoundaryEvents/ParameterMappings/Parameters use int32(2).

2. Workflow Parameter Entity Format (writer_workflow.go)

Changed Workflows$Parameter from deleted EntityRef (PartProperty object) to Entity (ByNameReferenceProperty string). Added Name: "WorkflowContext".

// Before (wrong - deleted in 9.10.0)
EntityRef: { $Type: "DomainModels$IndirectEntityRef", EntityQualifiedName: "..." }

// After (correct for Mendix >= 9.10.0)
Entity: "Module.EntityName"
Name: "WorkflowContext"

3. CallWorkflowActivity ParameterMappings (workflow.go, writer_workflow.go, cmd_workflows_write.go)

  • Added ParameterMappings []*ParameterMapping field to CallWorkflowActivity struct
  • Writer now serializes actual mappings (type Workflows$WorkflowCallParameterMapping)
  • Executor auto-binds $WorkflowContext expression via autoBindCallWorkflow()
  • Added ExecuteAsync: false field

4. CallMicroflowTask Auto-binding (cmd_workflows_write.go)

  • autoBindCallMicroflow(): reads microflow params, generates MicroflowCallParameterMapping
  • Auto-generates VoidConditionOutcome (Default) when no outcomes specified
  • sanitizeActivityName(): converts spaces/hyphens to underscores for valid Mendix identifiers

5. UserTaskOutcome Value Field (writer_workflow.go, workflow.go, cmd_workflows_write.go)

  • Removed incorrect Caption/Name fields from serialization
  • Added required Value field (must be unique per UserTask)

CE Errors Fixed

Error Description Root Cause
CE0117 ×8 Error(s) in expression Wrong array marker int32(3)int32(2)
CE1850 Workflow context required Deleted EntityRef format
CE1871 Workflow parameters changed Missing ParameterMappings
CE6685 Microflow parameters changed Missing ParameterMappings
CE6686 Outcomes do not match Missing default outcome
CE7247 Name contains spaces Caption used as Name
CE1864 Duplicate outcome Missing Value field
CE1865 Value property empty Missing Value field

How to Verify

# 1. Build
make build

# 2. Create test MDL
cat > /tmp/test-wf.mdl << 'MDL'
CREATE WORKFLOW WorkflowBaseline.E2E_TestWorkflow
  PARAMETER $WorkflowContext: WorkflowBaseline.Entity
BEGIN
  PARALLEL SPLIT COMMENT 'First Parallel'
    PATH 1 {
      CALL MICROFLOW WorkflowBaseline.Microflow;
      CALL MICROFLOW WorkflowBaseline.Microflow;
    }
    PATH 2 {
      CALL MICROFLOW WorkflowBaseline.Microflow_3;
    };
  CALL WORKFLOW WorkflowBaseline.Sub_Workflow;
  PARALLEL SPLIT COMMENT 'Second Parallel'
    PATH 1 { CALL WORKFLOW WorkflowBaseline.Sub_Workflow; }
    PATH 2 {
      CALL MICROFLOW WorkflowBaseline.Microflow;
      CALL WORKFLOW WorkflowBaseline.Sub_Workflow;
    };
  WAIT FOR NOTIFICATION COMMENT 'Await Signal';
  CALL MICROFLOW WorkflowBaseline.Microflow;
END WORKFLOW
/
MDL

# 3. Execute into baseline project (GenAIDemo)
./bin/mxcli exec /tmp/test-wf.mdl -p /path/to/App.mpr

# 4. mx check — expect 0 errors
~/.mxcli/mxbuild/11.6.4/modeler/mx check /path/to/App.mpr

# 5. DESCRIBE round-trip — verify ParameterMappings shown
./bin/mxcli -p /path/to/App.mpr -c "DESCRIBE WORKFLOW WorkflowBaseline.E2E_TestWorkflow;"

# 6. Cleanup
git -C /path/to/project checkout -- . && git clean -fd mprcontents/

Expected: 0 errors, DESCRIBE shows ParameterMappings for all CallMicroflow/CallWorkflow activities.

Files Changed

  • sdk/workflows/workflow.go — Added ParameterMappings to CallWorkflowActivity, Value to UserTaskOutcome
  • sdk/mpr/writer_workflow.go — Fixed array markers, parameter format, outcome serialization, added ExecuteAsync
  • mdl/executor/cmd_workflows_write.go — Added auto-bind logic, name sanitization, outcome Value

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions