Fix an unqualified association datasource that wrote an unloadable page (#854 follow-on) - #119
Merged
Merged
Conversation
…unloadable page Upstream mendixlabs#854 reported a cross-module association datasource writing an empty DestinationEntity, which Mendix resolves to null so the .mpr will not open. That half no longer reproduces — the destination resolves through CrossAssociations, and an unresolved one is refused. The association half of the same EntityRefStep was still written as authored. Both halves are BY_NAME references and Mendix nulls either one it cannot find, so a bare `Order_Line` produced the identical unopenable project, one property over: ArgumentNullException at EntityRefStep.set_AssociationId The explicit-destination form is what made it reachable: supplying the destination satisfies the empty-DestinationEntity guard, so nothing else stood between a bare name and the crash — and `Assoc/Module.Entity` is exactly the spelling that guard's error message tells the author to use. Qualify a bare association with the context entity's module, the rule attribute-path hops already follow, and verify an author-supplied destination's association exists rather than taking it on trust (a misspelling would otherwise be written qualified-but-nonexistent and null the same way). Verified on Mendix 11.13.0: all five spellings resolve and mx check reports 0 errors. The pre-fix binary reproduces the crash on the same script. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013uQvFDd5R4eNqqita59jM8
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.
Investigating upstream #854 found the reported bug already fixed and a second, unreported crash in the same code still live. This fixes the second one.
Verified against mxbuild 11.13.0 throughout.
mendixlabs#854 as filed does not reproduce
Two commits landed on 6 Aug — the day the issue was filed, and after the v0.16.0 the reporter used:
f0d1aearesolves cross-module associations throughCrossAssociations, and18de30brefuses to write an unresolved destination at all.Built the pre-fix parent (
a306810) and ran the same qualified script on both, changing one variable:DestinationEntity(pre-fix)mx check(pre-fix)ModA.Order_Note(same module)ModA.NoteModA.Order_Line(→ModB.Line)""ArgumentNullExceptionatset_DestinationEntityIdWhich is the reporter's claim exactly, including "same-module works". On
mainboth resolve andmx checkreports 0 errors.Worth recording the misstep: the first attempt ran bare names pre-fix and qualified names post-fix. Two variables, so the "reproduction" showed nothing about cross-module. Holding the script constant across the two builds is what isolated it.
What is still broken
An
EntityRefStephas two BY_NAME halves and Mendix resolves either one it cannot find to null. Only the destination was guarded. So on currentmain:writes
Association: "Order_Line"— unqualified — and the project dies on load:Same unopenable project as mendixlabs#854, one property over.
The explicit-destination form is what makes it reachable: supplying the destination satisfies the empty-DestinationEntity guard, so nothing else stood between a bare name and the crash — and
Assoc/Module.Entityis precisely the spelling that guard's error message tells the author to use. The fix's own advice walked you into the adjacent crash.The change
In
buildDataSourceV3'sassociationcase:resolveAssociationPathIn— the rule attribute-path hops already follow, and the one the skill documents.associationEndpointsinstead of taking it on trust. A misspelled (or wrongly-moduled) name would otherwise be written qualified-but-nonexistent and null exactly the same way; the refusal names the context entity so the "declared in another module" case is actionable.Both halves of the step are now guarded, not just the reported one.
Verification
Five spellings, all resolving to
ModA.Order_Line/ModB.Line:Order_Note(bare, same module)Order_Line(bare, cross-module)Order_Line/ModB.LineModA.Order_LineModA.Order_Line/ModB.Linemx checkon the built project: 0 errors, 0 best-practice recommendations.it-14-assoc-destination-entity.mdlre-run end to end: the existing System-module forms still resolve, so the new existence check does not regress associations mxcli cannot see in the project's own domain models.go test ./...,make check-mdl,make check-skill-mdlgreen.Two things to know
mx checkexits 0 on this class of failure. The loader dies before validation, so anything asserting on$?will call a dead project healthy — assert on thecontains: N errorsline instead. Noted in the symptom-table row.make fmtreformats 11 files unrelated to this change that are already unformatted onmain. I reverted them rather than bundle unrelated churn, so the tree is not gofmt-clean at HEAD. Worth a separate housekeeping commit.🤖 Generated with Claude Code
https://claude.ai/code/session_013uQvFDd5R4eNqqita59jM8
Generated by Claude Code