Skip to content

fix: parse_xpath keeps what follows true() / false() (closes #1894) - #1895

Closed
Joshua-TOF wants to merge 1 commit into
mendixlabs:mainfrom
Joshua-TOF:fix/parse-xpath-true-false
Closed

Joshua-TOF wants to merge 1 commit into
mendixlabs:mainfrom
Joshua-TOF:fix/parse-xpath-true-false

Conversation

@Joshua-TOF

Copy link
Copy Markdown

Closes #1894

What. parse_xpath returns the whole tree of an XPath that uses true() or false():

XPath Before After
[IsConfidential = false() or Mod.Report_Owner = '[%CurrentUser%]'] (IsConfidential = false) ((IsConfidential = false) OR (Mod.Report_Owner = '[%CurrentUser%]'))
[Name = 'x' 'y'] (Name = 'x') a recovered root with the whole source

Why. true() / false() is how Mendix XPath constraints usually write a Boolean, so access rules hit this often. A lint rule that checks whether every or branch of an access rule leads to the current user judged a fragment of the constraint, and which fragment depended on the order of its terms. The partial tree also gave no sign that anything was missing.

How.

  • mdl/exprcheck/parser.go, parseIdentLed: in XPath mode, true / false followed by () consume the empty argument list and stay a BoolLit. Without XPath mode nothing changes, so false() in a microflow expression is still E014.
  • mdl/linter/starlark.go, builtinParseXPath: when Parse reports E014 (tokens left over), it returns a recovered root holding the whole source, with the hint's problem as reason, as the write-lint-rules skill says parse failures do. Before, the hints were discarded and the partial tree came back as if it were complete.

XPath mode is only set in builtinParseXPath, so check, exec and describe are unaffected, and no bundled lint rule calls parse_xpath.

Testing.

  • mdl/exprcheck/xpath_mode_test.go: three XPaths with true() / false() in either or order and inside parentheses parse with no E014 and keep their top-level or / and; Active = true() gives a BoolLit; $X = false() or $Y as an expression still reports E014.
  • mdl/linter/starlark_xpath_paths_test.go: parse_xpath renders the full tree for those XPaths through a Starlark rule, and returns recovered with the whole source for [Name = 'x' 'y'].
  • On Linux (WSL, Go 1.27.4, parser generated with ANTLR 4.13.2): mdl/executor, mdl/exprcheck/..., mdl/linter, mdl/exprcatalog, cmd/mxcli/syntax and cmd/mxcli/testrunner pass, on main and on this branch.
  • go vet reports nothing; gofmt is clean. make lint not run.
  • A build of this branch, run with a printing lint rule on an app's access rules of the same shapes (an or with false() first, and a nested and / or): the full trees, where v0.31.0 returns only the first comparison.

🤖 Generated with Claude Code

…bs#1894)

In XPath mode parseIdentLed returned a BoolLit for true/false before the
'(' check, so the empty argument list of true() / false() was left on the
stream. The parse ended there and Parse reported E014; builtinParseXPath
discarded the hints, so a rule got the first comparison of
[IsConfidential = false() or Mod.Report_Owner = '[%CurrentUser%]'] as if
it were the whole constraint.

- XPath mode consumes the empty () after true / false. In a microflow
  expression false() stays an error (E014).
- parse_xpath returns a recovered root, with the whole source, when the
  parse leaves tokens over (E014), as the write-lint-rules skill says
  parse failures do.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@Joshua-TOF

Copy link
Copy Markdown
Author

Closing: the same fix landed on main through #1899 (commit 59350fa). parse_xpath now reads true()/false() and returns a recovered root for a partial parse.

@Joshua-TOF Joshua-TOF closed this Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lint: parse_xpath drops everything after true() / false()

1 participant