Skip to content

create published rest service writes only path parameters: query and body parameters fail mx check (CE0350, CE6539) #1206

Description

@tgolembiewski

Summary

create published rest service writes only the operation's path parameters. Every other microflow parameter is left out, so mx check fails on the service:

  • a query parameter gets CE0350;
  • a body gets CE0350;
  • a path parameter whose microflow parameter is not a String gets CE6539, because the path parameter is always written as a String.

The MDL has no way to declare operation parameters. So a service whose operation takes anything but a String path segment cannot be built from MDL. The workaround is to take System.HttpRequest and parse Uri by hand in the microflow.

Reproduce

On a blank Mendix 11.12.1 app:

create module RestQ;

create persistent entity RestQ.Upload extends System.FileDocument (
  Label: String(100)
);

create microflow RestQ.GetStatus ($orderNumber: String, $count: Integer, $httpRequest: System.HttpRequest)
returns String as $Result
begin
  declare $Result String = $orderNumber + ':' + toString($count);
  return $Result;
end;
/

create microflow RestQ.GetById ($id: Integer, $verbose: Boolean)
returns String as $Result
begin
  declare $Result String = toString($id);
  return $Result;
end;
/

create microflow RestQ.PutFile ($file: RestQ.Upload)
returns String as $Result
begin
  declare $Result String = 'ok';
  return $Result;
end;
/

create published rest service RestQ.PRS_Orders (
  Path: 'rest/orders/v1',
  Version: '1.0.0',
  ServiceName: 'Orders'
)
{
  resource 'orders' {
    GET 'status' microflow RestQ.GetStatus;
    GET 'items/{id}' microflow RestQ.GetById;
    POST 'upload' microflow RestQ.PutFile;
  }
};
/

mx check on v0.24.0 (also main at bf119f6):

[error] [CE0350] "Microflow 'GetStatus' has parameters that are not parameters of the operation: 'orderNumber', 'count'."
[error] [CE0350] "Microflow 'GetById' has a parameter that is not a parameter of the operation: 'verbose'."
[error] [CE0350] "Microflow 'PutFile' has a parameter that is not a parameter of the operation: 'file'."
[error] [CE6539] "Parameter 'id' has type 'String' in the operation, but type 'Integer/Long' in the microflow."
The app contains: 4 errors.

Cause

publishedRestOperationToGen in mdl/backend/modelsdk/published_rest_write.go has two limits:

  • It builds Rest$RestOperationParameter elements only from the {name} placeholders in the path, and gives each one DataTypes$StringType.
  • It never looks at the operation's microflow. $orderNumber, $count, $verbose and $file get no operation parameter, and $id gets the wrong type.

Studio Pro derives the operation's parameters from its microflow (Published REST Operation). The rule:

Microflow parameter Operation parameter
named in the path a path parameter
an object or a list the body
System.HttpRequest, System.HttpResponse none; they are the request and the response
anything else a query parameter

The metamodel already has every kind (Rest$RestOperationParameter.ParameterType: Path, Query, Header, Body, Form); mxcli only writes Path.

Proposed fix

When the service is written (create and alter, which writes every operation again), derive each operation's parameters from its microflow with the rule above, each with the microflow parameter's own type.

When the microflow does not exist yet, keep today's path-only behaviour and print a warning. The operation cannot get its other parameters until the microflow exists.

No new syntax is needed, and describe → exec stays a fixed point. The derivation is deterministic, and re-executing the describe output reports the service unchanged.

With this change the repro above passes mx check with 0 errors. At runtime, GET rest/orders/v1/orders/status?orderNumber=ORD%2F2026%2F0012&count=3 answers ORD/2026/0012:3.

I have this ready with tests and can open a PR.

Out of scope, noted for separate issues:

  • a body that is not a file document also needs an import mapping (CE6541). IMPORT MAPPING / EXPORT MAPPING / COMMIT on an operation are parsed but never written;
  • Header parameters, which Studio Pro does not derive;
  • service authentication (AuthenticationTypes is always empty).

Environment: mxcli v0.24.0 and main bf119f6, Mendix 11.12.1, macOS.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions