Skip to content

bug: XPath [%CurrentDateTime%] token written as quoted string literal → CE0161 #20

@engalar

Description

@engalar

Summary

Mendix special XPath tokens ([%CurrentDateTime%], [%CurrentUser%], etc.) are incorrectly written to BSON as quoted string literals ('[%CurrentDateTime%]'). This causes CE0161 (XPath parse error) when the project is opened in Studio Pro.

Repro

CREATE PERSISTENT ENTITY XpathTest.Order ( OrderDate: DateTime );

CREATE MICROFLOW XpathTest.GetRecentOrders () RETURNS List of XpathTest.Order (
  RETRIEVE $Orders FROM DATABASE XpathTest.Order
    WHERE $this/OrderDate > [%CurrentDateTime%]
  RETURN $Orders
);

Result: CE0161 XPath '[%CurrentDateTime%]' for constraint of retrieve ... is invalid

Root cause

The MDL writer treats the token as a string and wraps it in single quotes in the BSON XPath field. Mendix expects the token unquoted inside the constraint expression.

Impact

  • Any XPath constraint using [%CurrentDateTime%], [%CurrentUser%], [%BeginOfCurrentDay%], etc. produces a broken project
  • File 16-xpath-examples.mdl fails mx check with this error

Severity

HIGH — runtime XPath error, project is non-functional.

Discovered via

Automated roundtrip test — mdl-examples/doctype-tests/16-xpath-examples.mdl (2026-03-25)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions