Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"area":"mdl/executor","date":"2026-12-01","symptom":"A workflow call microflow activity whose microflow returns a String, an Integer or an object (CE6678), or takes a parameter other than the context entity with no mapping (CE0117), and a workflow decision on a String or Integer attribute (CE0078), all passed check -p and exec; MxBuild 11.16.1 rejected them. Check-gap sweep 3 f59 f60","cause":"The workflow signature checker judged user-task pages, targeting and completion microflows, but not the call-microflow activity's microflow or the decision condition. A stored microflow's signature also carried no ReturnKind (only the script's did), so return-type rules could not judge a project microflow at all","file":"mdl/executor/validate_workflow_call_signature.go (checkCallMicroflowSignature, checkDecisionCondition, sdkReturnKind), validate_workflow_task_signature.go, validate_datasource_args.go (sdkFlowSignature sets ReturnKind)","insight":"The context entity's parameter is passed implicitly (an unmapped $C: Ctx builds clean) while any other unmapped parameter is CE0117: judge the parameter by type, not by whether a mapping exists. An enumeration return is legal for the call microflow but needs matching outcomes (CE6686), a separate rule left unjudged; the agreement run shows it as the one expected mismatch. Filling ReturnKind for stored signatures widens every return-type rule that reads flowSignature, so run the rules that already used it (the multi-user completion microflow, CE5012) before trusting the change.","refs":["ako/mxcli#1258"],"ce":["CE6678","CE0117","CE0078"]}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
- **`check` and `lint` flag a decision captioned with its whole condition** (ako/mxcli#2685) — Studio Pro draws a decision's caption inside the diamond, and an `if` with no `@caption` was captioned with its full condition, so `$Stints != empty and length($Stints/json) >= 2` wrapped mid-token there and repeated the Expression field. `check` now reports an `if` or `elsif` with no `@caption` whose condition uses `and`/`or` or is longer than 40 characters (MDL-CAPTION01, info), and lint rule CONV012 reports a stored decision captioned with such a condition. A short single test is still its own caption, and `@caption ''` is not reported. The write-microflows skill and `mxcli syntax microflow.control-flow` now tell authors to caption decisions with a short phrase (`@caption 'Has stints?'`).

### Fixed
- **`check -p` rejects workflow call microflows and decisions the build rejects** (ako/mxcli#1258) — these passed `check -p` and `exec`, and MxBuild 11.16.1 then failed the build:
- A workflow `call microflow` whose microflow returns a String, an Integer or an object (CE6678). The microflow must return a Boolean, an enumeration or nothing.
- A workflow `call microflow` whose microflow takes a parameter other than the workflow's context object without a mapping (CE0117). The context object is passed automatically.
- A workflow `decision` on a String or Integer attribute (CE0078).

These checks now read return types for microflows already in the project, not only those the script creates.
- **`check` rejects five domain and microflow mistakes the build rejects** (ako/mxcli#1258) — these passed `check -p` and `exec`, and MxBuild 11.16.1 then failed the build:
- A `call java action` argument of the wrong type, such as `'abc'` or `1.5` for an Integer parameter (CE0117). Java action arguments now follow the same rules as microflow call arguments.
- A `create` or `change` that sets an association to an object of another entity (CE0117).
Expand Down
29 changes: 29 additions & 0 deletions mdl-examples/bug-tests/check-gap-workflows.mdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
-- check-gap f59/f60 (ako/mxcli#1258): the workflow forms MxBuild 11.16.1 builds
-- clean. check -p reports the rejected twins (each measured, one workflow per
-- case): a call microflow activity whose microflow returns a String, an Integer
-- or an object (CE6678), or takes a parameter other than the context entity
-- with no mapping (CE0117); a decision on a String or Integer attribute (CE0078).
-- They need a project, so they are covered in
-- mdl/executor/check_gap_workflows_test.go rather than a .fail.mdl.
mdl 1;
create module WfOk;
create persistent entity WfOk.Request (Title: String(100), Amount: Integer, Urgent: Boolean);
create microflow WfOk.IsLarge ($Request: WfOk.Request) returns Boolean as $Large begin return $Request/Amount > 1000; end;
create microflow WfOk.Notify ($Request: WfOk.Request) begin log info node 'wf' 'notified'; end;

create workflow WfOk.Approve
parameter $WorkflowContext: WfOk.Request
display 'Approve request'
begin
call microflow WfOk.Notify;
decision $WorkflowContext/Urgent
outcomes
true -> { call microflow WfOk.Notify; }
false -> { }
;
decision $WorkflowContext/Amount > 1000
outcomes
true -> { call microflow WfOk.Notify; }
false -> { }
;
end workflow;
4 changes: 2 additions & 2 deletions mdl-examples/check-gap/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ before measuring (a syntax error; a mistake `check` already refused). Rows here
| f56 | two pages with the same URL | CE5600 URL is conflicting |
| f57 | a home page that takes a parameter | CE0529 required parameter, cannot be the home page |
| f58 | a scheduled event whose microflow takes a parameter | CE7247 should not have parameters | — now `check`: MDL124
| f59 | a workflow `call microflow` on a microflow returning String | CE6678 must return Boolean, enumeration or nothing; CE0117 |
| f60 | a workflow decision on a String | CE0078 should be boolean or enumeration |
| f59 | a workflow `call microflow` on a microflow returning String | CE6678 must return Boolean, enumeration or nothing; CE0117 | — now `check -p`
| f60 | a workflow decision on a String | CE0078 should be boolean or enumeration | — now `check -p`
| f62 | a Java action argument of the wrong type (`'abc'` for an Integer) | CE0117 | — now `check -p`
| f67 | `create` setting an association to an object of the wrong entity | CE0117 | — now `check -p`
| f68 | a retrieve over an association from an entity that is not an end of it | CE0020 not connected, CE0136 | — now `check -p`
Expand Down
77 changes: 77 additions & 0 deletions mdl/executor/check_gap_workflows_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// SPDX-License-Identifier: Apache-2.0

package executor

import (
"strings"
"testing"
)

// Check-gap sweep 3, the workflow batch (f59 f60): each passed check -p and
// exec, and MxBuild 11.16.1 rejected the project. Every case below was measured
// there, one project per case.
const wfgHead = `mdl 1;
create module WFG;
create enumeration WFG.Color (Red 'Red', Blue 'Blue');
create persistent entity WFG.Ctx (N: String(10), Qty: Integer, B: Boolean, C: enumeration(WFG.Color));
create persistent entity WFG.Other (L: String(10));
create microflow WFG.A () begin log info node 'x' 'y'; end;
`

func wfgFlow(mf, body string) string {
return mf + "\ncreate workflow WFG.WF parameter $WorkflowContext: WFG.Ctx display 'W' begin " + body + " end workflow;\n"
}

func wfgCheck(t *testing.T, src string) string {
t.Helper()
exec, _, dir := openPedAppCopy(t)
return strings.Join(agreeCheck(t, exec, dir, src), "\n")
}

func TestCheckGapWorkflows_Reported(t *testing.T) {
cases := []struct{ name, src, want string }{
// f59: a call microflow activity's microflow must return a Boolean, an
// enumeration or nothing — CE6678.
{"returns String", wfgFlow("create microflow WFG.M () returns String as $R begin return 'x'; end;", "call microflow WFG.M;"),
"WFG.M returns String"},
{"returns Integer", wfgFlow("create microflow WFG.M () returns Integer as $R begin return 1; end;", "call microflow WFG.M;"),
"WFG.M returns Integer"},
{"returns an object", wfgFlow("create microflow WFG.M () returns WFG.Other as $R begin $R = create WFG.Other (); return $R; end;", "call microflow WFG.M;"),
"WFG.M returns WFG.Other"},
// A parameter that is not the context entity and has no mapping — CE0117.
{"unmapped String parameter", wfgFlow("create microflow WFG.M ($S: String) begin log info node 'x' $S; end;", "call microflow WFG.M;"),
"WFG.M takes $S, which nothing passes"},
{"unmapped other-entity parameter", wfgFlow("create microflow WFG.M ($O: WFG.Other) begin log info node 'x' 'y'; end;", "call microflow WFG.M;"),
"WFG.M takes $O, which nothing passes"},
// f60: a decision on a non-Boolean, non-enumeration attribute — CE0078.
{"decision on String", wfgFlow("", "decision $WorkflowContext/N outcomes true -> { call microflow WFG.A; } false -> { } ;"),
"is String, not a Boolean or an enumeration"},
{"decision on Integer", wfgFlow("", "decision $WorkflowContext/Qty outcomes true -> { call microflow WFG.A; } false -> { } ;"),
"is Integer, not a Boolean or an enumeration"},
}
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
got := wfgCheck(t, wfgHead+c.src)
if !strings.Contains(got, c.want) {
t.Errorf("check -p must report %q, reported:\n%s", c.want, got)
}
})
}
}

func TestCheckGapWorkflows_ControlsAccepted(t *testing.T) {
srcs := []string{
wfgFlow("create microflow WFG.M () returns Boolean as $R begin return true; end;", "call microflow WFG.M;"),
wfgFlow("create microflow WFG.M () begin log info node 'x' 'y'; end;", "call microflow WFG.M;"),
wfgFlow("create microflow WFG.M ($C: WFG.Ctx) begin log info node 'x' 'y'; end;", "call microflow WFG.M;"),
wfgFlow("", "decision $WorkflowContext/B outcomes true -> { call microflow WFG.A; } false -> { } ;"),
wfgFlow("", "decision $WorkflowContext/Qty > 1 outcomes true -> { call microflow WFG.A; } false -> { } ;"),
}
for _, s := range srcs {
t.Run(s, func(t *testing.T) {
if got := wfgCheck(t, wfgHead+s); got != "" {
t.Errorf("control must pass check -p, reported:\n%s", got)
}
})
}
}
2 changes: 1 addition & 1 deletion mdl/executor/validate_datasource_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ func buildFlowSignatures(ctx *ExecContext) map[string]*flowSignature {
}

func sdkFlowSignature(params []*microflows.MicroflowParameter, ret microflows.DataType) *flowSignature {
sig := &flowSignature{Returns: sdkDataTypeEntity(ret)}
sig := &flowSignature{Returns: sdkDataTypeEntity(ret), ReturnKind: sdkReturnKind(ret)}
switch {
case ret == nil:
case isSDKListType(ret):
Expand Down
156 changes: 156 additions & 0 deletions mdl/executor/validate_workflow_call_signature.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
// SPDX-License-Identifier: Apache-2.0

package executor

import (
"fmt"
"strings"

"github.com/mendixlabs/mxcli/mdl/ast"
"github.com/mendixlabs/mxcli/mdl/visitor"
"github.com/mendixlabs/mxcli/sdk/microflows"
)

// The workflow batch of the third check-gap parity sweep (mdl-examples/check-gap
// f59 f60): each passed check -p and exec, and MxBuild 11.16.1 rejected the
// project. Measured there, one workflow per case, context entity Sp.Ctx:
//
// call microflow M, M returns String / Integer / an object
// CE6678 "Call microflow expects a microflow returning a boolean value, an
// enumeration value, or nothing, but the selected microflow … returns …"
// call microflow M, M returns Boolean / nothing clean
// call microflow M, M takes ($S: String) or ($O: Sp.Other), unmapped CE0117
// call microflow M, M takes ($C: Sp.Ctx), unmapped clean
// decision $WorkflowContext/N (String) or /Qty (Integer)
// CE0078 "Condition should be of type boolean or enumeration but is of type …"
// decision $WorkflowContext/B, or $WorkflowContext/Qty > 1 clean
//
// A microflow returning an enumeration also needs its outcomes to match (CE6686),
// which is not judged here. Anything this checker cannot establish — a
// microflow neither the script nor the project declares, a parameter entity
// whose inheritance cannot be read, an attribute of unknown type — is silence.

// checkCallMicroflowSignature reports a workflow call-microflow activity whose
// microflow returns something a workflow cannot branch on, or takes a parameter
// nothing passes.
func (c *workflowTaskSignatureChecker) checkCallMicroflowSignature(label string, n *ast.WorkflowCallMicroflowNode, contextEntity string) []string {
mfQN := n.Microflow.String()
if mfQN == "" || mfQN == "." {
return nil
}
sig, ok := c.flowSignature(mfQN)
if !ok || sig == nil {
return nil
}
var errs []string
switch sig.ReturnKind {
case ast.TypeUnknown, ast.TypeVoid, ast.TypeBoolean, ast.TypeEnumeration:
default:
ret := sig.ReturnKind.String()
if sig.Returns != "" {
ret = sig.Returns
if sig.ReturnKind == ast.TypeListOf {
ret = "List of " + sig.Returns
}
}
errs = append(errs, fmt.Sprintf(
"%s: microflow %s returns %s — a workflow's call microflow must return a Boolean, an enumeration or nothing "+
"(its outcomes branch on the result); the build fails CE6678", label, mfQN, ret))
}
mapped := map[string]bool{}
for _, pm := range n.ParameterMappings {
mapped[strings.ToLower(strings.TrimPrefix(strings.TrimSpace(pm.Parameter), "$"))] = true
}
for _, p := range sig.Params {
if mapped[strings.ToLower(p.Name)] || p.List {
continue
}
if p.Object && p.Entity != "" {
if contextEntity == "" || contextEntity == "." || c.contextAssignableTo(contextEntity, p.Entity) != inheritanceNo {
continue
}
}
errs = append(errs, fmt.Sprintf(
"%s: microflow %s takes $%s, which nothing passes — the workflow passes its context object (%s) by itself, "+
"any other parameter needs a mapping (`call microflow %s with (%s = …)`); the build fails CE0117",
label, mfQN, p.Name, contextEntity, mfQN, p.Name))
}
return errs
}

// checkDecisionCondition reports a workflow decision whose condition is a single
// context attribute that is neither a Boolean nor an enumeration (CE0078).
func (c *workflowTaskSignatureChecker) checkDecisionCondition(label, expr, contextEntity string) string {
if strings.TrimSpace(expr) == "" || contextEntity == "" || contextEntity == "." {
return ""
}
e, ok := visitor.ParseExpressionText(expr)
if !ok {
return ""
}
p, ok := unwrapWorkflowExpr(e).(*ast.AttributePathExpr)
if !ok || !strings.EqualFold(strings.TrimPrefix(p.Variable, "$"), workflowContextVar) {
return ""
}
steps := expressionPathSteps(p)
if len(steps) != 1 || strings.Contains(steps[0], ".") {
return ""
}
t, ok := retrieveAttributeType(c.ctx, c.sc, contextEntity, steps[0])
if !ok {
return ""
}
switch t.Kind {
case ast.TypeUnknown, ast.TypeBoolean, ast.TypeEnumeration:
return ""
}
return fmt.Sprintf(
"%s: the condition %s is %s, not a Boolean or an enumeration — a decision branches on true/false or on an "+
"enumeration's values; the build fails CE0078 (compare it, such as `%s != empty`)",
label, strings.TrimSpace(expr), t.Kind.String(), strings.TrimSpace(expr))
}

func unwrapWorkflowExpr(e ast.Expression) ast.Expression {
for {
switch x := e.(type) {
case *ast.SourceExpr:
e = x.Expression
case *ast.ParenExpr:
e = x.Inner
default:
return e
}
}
}

// sdkReturnKind is a stored microflow's return type as the AST spells it, so a
// signature read from the project answers return-type questions as one the
// script declares does. TypeUnknown for a type not mapped here.
func sdkReturnKind(ret microflows.DataType) ast.DataTypeKind {
if ret == nil {
return ast.TypeVoid
}
switch ret.GetTypeName() {
case "Void":
return ast.TypeVoid
case "Boolean":
return ast.TypeBoolean
case "String":
return ast.TypeString
case "Integer":
return ast.TypeInteger
case "Long":
return ast.TypeLong
case "Decimal":
return ast.TypeDecimal
case "DateTime":
return ast.TypeDateTime
case "Enumeration":
return ast.TypeEnumeration
case "Object":
return ast.TypeEntity
case "List":
return ast.TypeListOf
}
return ast.TypeUnknown
}
9 changes: 9 additions & 0 deletions mdl/executor/validate_workflow_task_signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ func (c *workflowTaskSignatureChecker) checkActivities(activities []ast.Workflow
errs = appendIfSet(errs, c.checkAgentMicroflow("AI agent task "+workflowCallMicroflowLabel(cm), cm.Microflow.String()))
return
}
// Check-gap sweep 3 (validate_workflow_call_signature.go).
if cm, ok := a.(*ast.WorkflowCallMicroflowNode); ok {
errs = append(errs, c.checkCallMicroflowSignature("call microflow "+workflowCallMicroflowLabel(cm), cm, contextEntity)...)
return
}
if d, ok := a.(*ast.WorkflowDecisionNode); ok {
errs = appendIfSet(errs, c.checkDecisionCondition("decision "+workflowDecisionLabel(d), d.Expression, contextEntity))
return
}
n, ok := a.(*ast.WorkflowUserTaskNode)
if !ok {
return
Expand Down
Loading