Skip to content

Commit 54633e0

Browse files
akoclaude
andcommitted
fix: validate OData client ServiceUrl must be a constant reference
Studio Pro CE6825 requires the Service URL of a consumed OData service to be a Mendix constant (e.g. @Module.ServiceUrlConstant), not a string literal. Without this check mxcli silently wrote an invalid expression, causing CE0117 + CE6825 errors on mx check. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 666f15e commit 54633e0

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

mdl/executor/cmd_odata.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,9 @@ func createODataClient(ctx *ExecContext, stmt *ast.CreateODataClientStmt) error
919919
svc.HttpConfiguration = &model.HttpConfiguration{}
920920
}
921921
if stmt.ServiceUrl != "" {
922+
if err := validateServiceURL(stmt.ServiceUrl); err != nil {
923+
return err
924+
}
922925
svc.HttpConfiguration.OverrideLocation = true
923926
svc.HttpConfiguration.CustomLocation = stmt.ServiceUrl
924927
}
@@ -998,6 +1001,9 @@ func createODataClient(ctx *ExecContext, stmt *ast.CreateODataClientStmt) error
9981001
ClientCertificate: stmt.ClientCertificate,
9991002
}
10001003
if stmt.ServiceUrl != "" {
1004+
if err := validateServiceURL(stmt.ServiceUrl); err != nil {
1005+
return err
1006+
}
10011007
cfg.OverrideLocation = true
10021008
cfg.CustomLocation = stmt.ServiceUrl
10031009
}
@@ -1079,6 +1085,9 @@ func alterODataClient(ctx *ExecContext, stmt *ast.AlterODataClientStmt) error {
10791085
case "description":
10801086
svc.Description = strVal
10811087
case "serviceurl":
1088+
if err := validateServiceURL(strVal); err != nil {
1089+
return err
1090+
}
10821091
if svc.HttpConfiguration == nil {
10831092
svc.HttpConfiguration = &model.HttpConfiguration{}
10841093
}
@@ -1380,6 +1389,15 @@ func dropODataService(ctx *ExecContext, stmt *ast.DropODataServiceStmt) error {
13801389
return mdlerrors.NewNotFoundMsg("OData service", fmt.Sprint(stmt.Name), fmt.Sprintf("OData service not found: %s", stmt.Name))
13811390
}
13821391

1392+
// validateServiceURL returns an error if url is not a constant reference (@Module.Name).
1393+
// CE6825: Studio Pro requires the Service URL to be a constant, not a string literal.
1394+
func validateServiceURL(url string) error {
1395+
if !strings.HasPrefix(url, "@") {
1396+
return mdlerrors.NewValidation("ServiceUrl must be a constant reference (e.g., @Module.ServiceUrlConstant) — Studio Pro CE6825: 'Service URL' must be a constant")
1397+
}
1398+
return nil
1399+
}
1400+
13831401
// formatExprValue formats a Mendix expression value for MDL output.
13841402
// If the value is already a quoted string literal (starts/ends with '), it's output as-is.
13851403
// Otherwise, it's wrapped in single quotes for round-trip compatibility.

0 commit comments

Comments
 (0)