fix: remove invalid ParentConnection/ChildConnection from CrossAssociation BSON (#50)#105
Conversation
…s#50) Three bugs fixed: 1. Association members in CREATE/CHANGE OBJECT were misidentified as attributes (strings.Contains(".") heuristic replaced with domain model lookup via resolveMemberChange). 2. Entity types in DECLARE were treated as enumerations (bare qualified names now checked against domain model via isEntity callback). 3. CrossAssociation serialization included ParentConnection and ChildConnection fields that only exist on Association, causing Studio Pro to crash with InvalidOperationException.
AI Code ReviewWhat Looks Good
RecommendationApprove. The PR correctly fixes a critical bug causing Studio Pro crashes, includes appropriate test coverage, improves documentation for similar future issues, and maintains code quality standards. The changes are focused, well-tested, and address the root cause without introducing regressions. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
ako
left a comment
There was a problem hiding this comment.
Review: Approve
Clean, well-scoped bug fix with good test coverage.
The fix is correct
CrossAssociation BSON: Root cause is clearly a copy-paste error — serializeCrossAssociation was cloned from serializeAssociation but kept ParentConnection and ChildConnection fields that don't exist on DomainModels$CrossAssociation. The Mendix type cache does a strict lookup and crashes on unknown fields. Removing them is the right fix.
resolveMemberChange fallback: The dot-contains heuristic (Module.Entity_Entity contains a dot → association, bare Name → attribute) is a reasonable fallback when no reader is available. Matches the convention that association names are always qualified while attribute names are bare.
Test quality is good
TestSerializeCrossAssociation_NoConnectionFields— checks both absence of invalid fields AND presence of all expected fields (exhaustive structural contract)TestSerializeAssociation_HasConnectionFields— regression guard ensuring the fix didn't accidentally remove fields from the wrong functionTestResolveMemberChange_FallbackWithoutReader— covers both attribute (no dot) and association (with dot) paths
The debug-bson.md additions are valuable
The Python BSON diffing script is a solid diagnostic workflow for future type-mismatch crashes. The CE1613 section documenting both variants (association-as-attribute and entity-as-enumeration) is useful context.
Summary
ParentConnectionandChildConnectionfields fromserializeCrossAssociation(). These properties only exist onDomainModels$Association, notDomainModels$CrossAssociation. Writing them causes Studio Pro to crash withSystem.InvalidOperationException: Sequence contains no matching elementinMprProperty..ctor.Module.Entity_Entityformat) from attributes, instead of treating everything as an attribute.Root Cause
The original
serializeCrossAssociationwas copy-pasted fromserializeAssociationwithout removing Association-only properties. Mendix's type cache expects strict field alignment with the metamodel — extra fields trigger a crash.Test plan
TestSerializeCrossAssociation_NoConnectionFields— verifies CrossAssociation omits Connection fieldsTestSerializeAssociation_HasConnectionFields— verifies regular Association still includes them (regression guard)TestResolveMemberChange_FallbackWithoutReader— verifies dot heuristic for attribute vs associationParentConnection/ChildConnectioncauses test failureCloses #50