Repository navigation
fix(check): refuse an association used as an XPath condition (#2793) - #2827
Merged
Merged
Conversation
`[M.Assoc]` and `not(M.Assoc)` in an access rule, a retrieve or a page datasource passed check and failed mxbuild with CE0161. Parse the constraint, walk condition positions, and report a path that ends on an association as MDL047 with the path-to-entity fix. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011oK82qrr1WnXxq1eRn7qRJ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2793 (upstream mendixlabs#2042).
Problem
[Module.Assoc]andnot(Module.Assoc)read like "has one" and "has none".checkaccepted them in an access rule, a retrieve and a page datasource. mxbuild rejects each one with CE0161 "Error(s) in XPath constraint.", including inside a nested predicate.Measured (11.12.6, security level Production)
[not(M.Doc_Org)],[M.Doc_Org][M.Doc_Org/M.Org[M.Org_Holder]],[… and not(M.Org_Holder)][not(M.Doc_Org/M.Org)],[M.Doc_Org/M.Org[not(M.Org_Holder/M.Holder)]]At security level Off, mx does not validate access-rule XPaths at all, so the bad rule reports 0 errors there.
Fix
xpathBareAssociationTermsparses the constraint and walks condition positions: the group root,and/oroperands,not()arguments and path-step predicates. A path made only of module-qualified steps, with an odd step count and no predicate on the last step, ends on an association, so no project is needed to tell. Each such path is reported as MDL047, the existing rule for the other association test XPath lacks (= empty), with the path-to-entity fix. The check runs from the microflow retrieve, access-rule and datasource validators.Tests
TestXPathBareAssociationTerms_Issue2793: 16 hit and legal forms.TestBareAssociationReachesEveryCheck_Issue2793: retrieve (with control), access rule, page datasource.make ci-localpassed. Finding recorded,make check-findingsOK.Generated by Claude Code