fix: augment nested ObjectType properties from .mpk to prevent CE0463#166
Conversation
When the installed widget version (.mpk) differs from the embedded template version, nested ObjectType properties (e.g., DataGrid2 column properties like tooltip, exportValue) were not being synced. This caused property count mismatches between Type and Object, triggering CE0463. Extended AugmentTemplate to recursively process nested ObjectType PropertyTypes for Object-type properties with children in the .mpk definition. This adds missing and removes stale nested properties in both the Type schema and Object values. Root cause fix for mendixlabs#121
AI Code ReviewWhat Looks GoodThe PR successfully addresses the CE0463 bug by extending the Key strengths:
Test coverage:
RecommendationApprove - The PR is ready for merge. It correctly fixes the CE0463 issue with minimal, focused changes, includes appropriate test coverage, and maintains code quality standards. No blocking issues identified. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
ako
left a comment
There was a problem hiding this comment.
Substantial fix targeting the root cause that PR #164 was working around. The approach is correct.
What's good
- Recursive sync of nested ObjectType PropertyTypes correctly handles add/remove for both Type schema and Object Properties
- Early-return fix is critical: previously
if len(missing) == 0 && len(stale) == 0 { return nil }would skip nested processing when top-level was already in sync. Now checkshasNestedChildren. - Exemplar-based cloning with
createPropertyPairfallback - TypePointer matching correctly identifies which Object Properties to update for stale removal
Concerns
Test coverage is thin. Only one test case (add missing). Missing:
- Removing stale nested properties (the ~50 lines of removal logic)
- Multiple WidgetObject instances (e.g., DataGrid with 3 columns — does the new property get added to all 3?)
- No-op case when nested is already in sync (regression guard for the early-return change)
Recursion depth. The function syncs one level of nesting. Worth confirming this is sufficient for all Mendix widget specs — does any widget have nested-nested ObjectTypes?
Unhandled: type change between versions. If .mpk changes a child from string → textTemplate, the function neither removes nor updates the type. Probably out of scope but worth noting.
Minor: The break in augmentNestedObjectType's objProps loop after finding matched TypePointer would benefit from a comment explaining why (only one property matches a given TypePointer).
LGTM — fix is correct for the documented scenario. Recommend expanding test coverage for stale removal and multi-instance cases in a follow-up.
Summary
AugmentTemplateto recursively sync nested ObjectType PropertyTypes (e.g., DataGrid2 column properties) with.mpkdefinitionsRoot Cause
When the project's
.mpkwidget version differs from the embedded template version,AugmentTemplateonly synced top-level properties. Nested ObjectType properties (like DataGrid2 column properties: tooltip, exportValue, showContentAs) were left with the original template's schema, causing Type/Object property count mismatches that trigger CE0463.What Changed
augment.go: AddedaugmentNestedObjectType()that processes.mpkchildren for Object-type propertiesaugment_test.go: Added test for nested ObjectType property additionRelationship to #164
PR #164 adds
mx update-widgetsas a workaround beforemx check. This PR fixes the underlying cause so the workaround is needed less often.Refs #121
Test plan
go build ./...andgo vetpass🤖 Generated with Claude Code