Skip to content

Commit e35eea2

Browse files
committed
fix: strip REST path slashes and validate microflow param entity refs
Root causes of TestMxCheck_DoctypeScripts failures: 1. REST service operation paths with leading/trailing slashes were stored as-is in BSON (CE6550/CE6551). Now stripped at parse time in visitor_rest.go. 2. Microflow parameters with bare entity names like "Object" (missing module prefix) were not caught by mxcli check. Added MDL008 validation in both ValidateMicroflow (linter) and ValidateMicroflowBody (semantic validator). 3. Test data fixes: REST param case mismatch ($Id → $id), workflow params (Object → System.Workflow/System.WorkflowUserTask).
1 parent c97c85b commit e35eea2

5 files changed

Lines changed: 28 additions & 11 deletions

File tree

mdl-examples/doctype-tests/22-published-rest-service-examples.mdl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ BEGIN
2323
END;
2424
/
2525

26-
CREATE MICROFLOW PrsTest.PRS_GetOrderById ($httpResponse: System.HttpResponse, $Id: String)
26+
CREATE MICROFLOW PrsTest.PRS_GetOrderById ($httpResponse: System.HttpResponse, $id: String)
2727
RETURNS String AS $Result
2828
BEGIN
2929
DECLARE $Result String = '{}';
@@ -39,7 +39,7 @@ BEGIN
3939
END;
4040
/
4141

42-
CREATE MICROFLOW PrsTest.PRS_DeleteOrder ($httpResponse: System.HttpResponse, $Id: String)
42+
CREATE MICROFLOW PrsTest.PRS_DeleteOrder ($httpResponse: System.HttpResponse, $id: String)
4343
RETURNS String AS $Result
4444
BEGIN
4545
DECLARE $Result String = '{"status": "deleted"}';

mdl-examples/doctype-tests/workflow-microflow-actions.mdl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
-- Verifies parsing of all 11 workflow action types in microflows
33

44
CREATE MICROFLOW TestModule.MF_WorkflowActions (
5-
$Workflow: Object,
6-
$ContextObj: Object,
7-
$UserTask: Object
5+
$Workflow: System.Workflow,
6+
$ContextObj: System.Workflow,
7+
$UserTask: System.WorkflowUserTask
88
)
99
RETURNS Nothing
1010
BEGIN

mdl/executor/cmd_microflows_builder_validate.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,16 @@ func ValidateMicroflowBody(s *ast.CreateMicroflowStmt) []string {
1616
varTypes := make(map[string]string)
1717
declaredVars := make(map[string]string)
1818

19+
var paramErrors []string
1920
for _, p := range s.Parameters {
2021
if p.Type.EntityRef != nil {
22+
// Reject bare entity names (empty module) — e.g., "Object" instead of "System.Workflow"
23+
if p.Type.EntityRef.Module == "" {
24+
paramErrors = append(paramErrors, fmt.Sprintf(
25+
"parameter '$%s': entity type '%s' is missing module prefix (use 'Module.%s')",
26+
p.Name, p.Type.EntityRef.Name, p.Type.EntityRef.Name))
27+
continue
28+
}
2129
entityQN := p.Type.EntityRef.Module + "." + p.Type.EntityRef.Name
2230
if p.Type.Kind == ast.TypeListOf {
2331
varTypes[p.Name] = "List of " + entityQN
@@ -29,6 +37,9 @@ func ValidateMicroflowBody(s *ast.CreateMicroflowStmt) []string {
2937
declaredVars[p.Name] = p.Type.Kind.String()
3038
}
3139
}
40+
if len(paramErrors) > 0 {
41+
return paramErrors
42+
}
3243

3344
// Create a validation-only flow builder
3445
fb := &flowBuilder{

mdl/executor/validate_microflow.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ func ValidateMicroflow(stmt *ast.CreateMicroflowStmt) []linter.Violation {
1717
mfName: stmt.Name.String(),
1818
returnType: stmt.ReturnType,
1919
}
20+
// Validate parameter entity references — reject bare names without module prefix
21+
for _, p := range stmt.Parameters {
22+
if p.Type.EntityRef != nil && p.Type.EntityRef.Module == "" {
23+
v.addViolation("MDL008", linter.SeverityError,
24+
fmt.Sprintf("parameter '$%s': entity type '%s' is missing module prefix",
25+
p.Name, p.Type.EntityRef.Name),
26+
fmt.Sprintf("Use a qualified name like 'Module.%s' or 'System.%s'",
27+
p.Type.EntityRef.Name, p.Type.EntityRef.Name))
28+
}
29+
}
2030
v.validate(stmt.Body)
2131
return v.violations
2232
}

mdl/visitor/visitor_rest.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,12 @@ func (b *Builder) ExitCreatePublishedRestServiceStatement(ctx *parser.CreatePubl
298298
opDef.HTTPMethod = strings.ToUpper(mCtx.GetText())
299299
}
300300

301-
// Operation path
301+
// Operation path — strip leading/trailing slashes (CE6550/CE6551)
302302
if pCtx := oc.PublishedRestOpPath(); pCtx != nil {
303303
pc := pCtx.(*parser.PublishedRestOpPathContext)
304304
if pc.STRING_LITERAL() != nil {
305-
opDef.Path = unquoteString(pc.STRING_LITERAL().GetText())
306-
} else {
307-
opDef.Path = "/"
305+
opDef.Path = strings.Trim(unquoteString(pc.STRING_LITERAL().GetText()), "/")
308306
}
309-
} else {
310-
opDef.Path = "/"
311307
}
312308

313309
// Microflow reference

0 commit comments

Comments
 (0)