Skip to content

check: MDL047 and the reference check read Assoc.Attr in an access-rule XPath as one association name and suggest a wrong fix #1916

Open

Description

@tgolembiewski

What happens

An access rule constraint that joins an association and an attribute with a dot instead of a path step:

grant read * on entity Repro.Car to Repro.R
  where [Car_Assignment.ReturnedOn = empty];

mxcli check (v0.32.0, -p on a Mendix 11.16.0 project) reports MDL047 and suggests:

✗ access rule on Repro.Car: the constraint tests association `Car_Assignment.ReturnedOn = empty`, which Mendix XPath does not support (CE0161 "Error(s) in XPath constraint") — `empty` compares attributes, not associations [MDL047]
    → Test for the absence of the associated object with negation: `[not(Car_Assignment.ReturnedOn/<Module.TargetEntity>)]`.

and the reference check says:

statement 6: grant on entity Repro.Car to Repro.R: the access rule's constraint names association "Car_Assignment.ReturnedOn", which is neither an attribute nor an association of Repro.Car

Both read Car_Assignment.ReturnedOn as one association name. The suggested fix keeps the dotted name and adds a target-entity step after it, so it is still wrong: ReturnedOn is an attribute of Repro.Assignment, and what is missing is the entity step between the association and the attribute.

The working forms (both pass check):

where [Repro.Car_Assignment/Repro.Assignment/ReturnedOn = empty]
where [Repro.Car_Assignment/Repro.Assignment[ReturnedOn = empty]]

Why it matters

An agent writing MDL followed the MDL047 suggestion and the reference error for about 40 minutes (about ten throwaway scratch modules, the same two messages each time) without finding the missing entity step. Neither message says that a path needs association/Entity/attribute.

Expected

When a constraint step is <association>.<name> where <association> exists on the entity and <name> is an attribute of the association's other end, report that a path step is missing and suggest [<Module.Association>/<Module.OtherEntity>/<attribute> ...], rather than the not(...) absence form, which fits only [Association = empty].

Repro

repro.mdl, checked with mxcli check repro.mdl -p <any 11.x project> --references:

mdl 1;
create module Repro;
create persistent entity Repro.Car (
  Name: String(20)
);
create persistent entity Repro.Assignment (
  ReturnedOn: DateTime
);
create association Repro.Car_Assignment
  FROM Repro.Assignment TO Repro.Car
  TYPE Reference;
create module role Repro.R;
grant read * on entity Repro.Car to Repro.R
  where [Car_Assignment.ReturnedOn = empty];

mxcli v0.32.0 (2026-11-15), macOS arm64, Mendix 11.16.0. Not tried on the nightly.

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