Skip to content

Commit 416d074

Browse files
committed
Merge remote-tracking branch 'origin/main' into claude/wonderful-hypatia-x7mmyq
# Conflicts: # CHANGELOG.md
2 parents 918ac2c + 0d2c028 commit 416d074

6 files changed

Lines changed: 258 additions & 5 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"area": "modelsdk/widgets", "date": "2026-10-22", "symptom": "CE0463 \"The definition of this widget has changed\" on every Marketplace Calendar (2.6.1, 11.12.5) written by mxcli, visible to a plain `mx check` but not to `mxcli docker check`, which runs update-widgets on a temporary copy first. The only difference from an update-widgets copy: the toolbarItems property (type=\"object\" isList=\"true\") stored ValueType.ObjectType null (mendixlabs/mxcli#1632).", "cause": "The .mpk parser read an object property's sub-properties only from `<properties><propertyGroup>`; the Calendar lists them directly under `<properties>`, each with a `<category>` element. PropertyDef.Children stayed empty, so GenerateFromMPK (the Calendar has no embedded template) wrote no nested WidgetObjectType.", "file": "modelsdk/widgets/mpk/mpk.go (xmlProperty.NestedDirectProps and Category, nestedGroups, collectNestedProperties takes a direct child's own <category>); tests modelsdk/widgets/mpk/objectdirect_test.go, modelsdk/widgets/objectdirect_test.go; example mdl-examples/bug-tests/1632-calendar-toolbaritems-definition.mdl", "insight": "The second .mpk parser, sdk/widgets/mpk (widget init, catalog, widget docs), already read both shapes and named PopupMenu basicItems and Maps markers as examples of the direct one; modelsdk/widgets/mpk had only the grouped one. PopupMenu and Maps never showed it because they have embedded templates, whose nested ObjectType comes from the template rather than the parser. When two parsers of one format exist, diff their xml struct tags first. Checking a generated widget against `mx update-widgets` on a copy, ids stripped, gives the exact field; `mxcli docker check` cannot, because it runs that same update before checking.", "refs": ["mendixlabs/mxcli#1632", "mendixlabs/mxcli#1578"], "ce": ["CE0463"]}

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
1616
### Fixed
1717

1818
- **`widget sync` keeps the integers it does not change as integers** (ako/mxcli#1976, mendixlabs/mxcli#1748) — syncing a widget wrote every int32 and int64 in it back as a double, a text box in the widget's slot included, whose `MaxLengthCode -1.0` Mendix reads as unlimited (CE6510). A unit already synced by an earlier version keeps its doubles; re-create the page to repair it.
19+
- **A Marketplace Calendar written by mxcli passes a plain `mx check`** (mendixlabs/mxcli#1632) — every Calendar failed with CE0463 "The definition of this widget has changed" until `mxcli fix widgets` or Studio Pro's "Update all widgets"; `mxcli docker check` hid it, since it runs that update on a temporary copy first. The Calendar's `toolbarItems` object list declares its sub-properties directly under `<properties>`, not inside a `<propertyGroup>`, and the `.mpk` parser behind generated widget templates read only the grouped shape, so the list was stored with no definition of its items. Both shapes are now read, a direct sub-property takes its category from its own `<category>` element, and the stored Calendar equals what `mx update-widgets` writes. The other object-list widgets in `doctype-tests/32-pluggable-widget-object-lists-v010.mdl` (Accordion, PopupMenu, Maps, area and line chart, heat map) are stored unchanged.
1920
- **`alter workflow` no longer guesses which outcome to drop** (ako/mxcli#808) — `drop X outcome 'V'` with two outcomes of value `V` dropped the first; it is refused as ambiguous now. `check --references` also resolves an activity reference by name before caption, as `exec` does, so its guards no longer go silent on a target captioned like another activity's name.
2021
- **describe → exec keeps a decision whose true branch is empty** (ako/mxcli#1963, mendixlabs/mxcli#1742) — `describe microflow` folded such a decision into `if not(X) then <false branch> end if;`, and executing that stored `not(X)` with the true and false outcomes swapped: the same behaviour, a different model in Studio Pro. It is now printed as stored, `if X then else <false branch> end if;`, which builds Studio Pro's shape. A script written from the old output still means the same thing; an `alter microflow` target written in the folded `if not(X) then` form no longer resolves, and is refused rather than applied.
2122
- **`marketplace install` installs protected (add-on) modules shipped as `.mxmodule`** — such a package carries its model not as an SQLite `.mpr` but as one BSON document holding the module as a tree, so install failed with `file is not a database`, and `mx module-import` refuses protected modules outright ("Importing protected module is not supported", exit 111). The reference project is now built by splitting that tree into units and writing them with the same raw-unit writer the transplant uses; protection settings travel unchanged. Measured on Menditect's MtaPluginModule 11.5.5 (Marketplace 214717) into an 11.15 MPR v2 app: 32 units, `mx check` 0 errors, module listed as *Protected AddOn*, and the plugin starts and serves its endpoint. The package's declared files (`javasource/`, `javascriptsource/`, …) are written beside the reference project as `mx module-import` would, so `marketplace diff` and `update` do not report every Java or JavaScript action as changed; the units are not converted to the project's Mendix version, so a package saved with a newer Mendix than the project is refused.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
-- mendixlabs/mxcli#1632: every Marketplace Calendar (content 245304, 2.6.1)
2+
-- written by mxcli passed `check` and `exec`, then a plain `mx check` failed:
3+
-- [CE0463] "The definition of this widget has changed. ..." at Calendar 'cal'
4+
-- `mxcli docker check` reported it clean, because it runs update-widgets on a
5+
-- temporary copy before checking.
6+
-- The Calendar has no embedded template, so its Type is generated from the
7+
-- .mpk. Its toolbarItems object list declares its sub-properties directly
8+
-- under <properties>, with no <propertyGroup>, and the parser read only the
9+
-- grouped shape: toolbarItems was stored with ObjectType null.
10+
-- After the fix, `mx check` reports no error for this page, and the stored
11+
-- page equals a copy that `mx update-widgets` rewrote (ids stripped).
12+
-- Needs: `mxcli marketplace install 245304 -p <app>` first.
13+
mdl 1;
14+
15+
create module BugTest1632;
16+
17+
create persistent entity BugTest1632.Shift (
18+
Title: String(200),
19+
StartsAt: DateTime,
20+
EndsAt: DateTime
21+
);
22+
23+
-- No toolbar item written: the object list is empty, its definition must
24+
-- still be complete.
25+
create or modify page BugTest1632.ShiftCalendar (Title: 'Shifts', Layout: Atlas_Core.Atlas_Default) {
26+
pluggablewidget 'com.mendix.widget.web.calendar.Calendar' cal (
27+
databaseDataSource: database BugTest1632.Shift,
28+
titleType: 'attribute',
29+
titleAttribute: Title,
30+
startAttribute: StartsAt,
31+
endAttribute: EndsAt
32+
)
33+
};

‎modelsdk/widgets/mpk/mpk.go‎

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,30 @@ type xmlProperty struct {
252252
ActionVariables []xmlActionVariable `xml:"actionVariables>actionVariable"`
253253
// Nested properties for object type
254254
NestedProps []xmlPropGroup `xml:"properties>propertyGroup"`
255+
// Nested properties an object type lists directly, with no propertyGroup
256+
// around them (the Marketplace Calendar's toolbarItems, PopupMenu
257+
// basicItems, Maps markers) — see nestedGroups. sdk/widgets/mpk already
258+
// reads both shapes.
259+
NestedDirectProps []xmlProperty `xml:"properties>property"`
260+
// Category of such a direct sub-property (<category>Appearance</category>);
261+
// grouped properties take theirs from the group captions instead.
262+
Category string `xml:"category"`
263+
}
264+
265+
// nestedGroups returns an object property's sub-properties as property groups.
266+
// The direct ones come back as one caption-less group, so each takes its own
267+
// <category>. Without them the object had no Children, its generated ObjectType
268+
// stayed nil, and mx check reported CE0463 (mendixlabs/mxcli#1632). Groups come
269+
// first, then the direct ones, the order sdk/widgets/mpk reads them in.
270+
func nestedGroups(p xmlProperty) []xmlPropGroup {
271+
if len(p.NestedDirectProps) == 0 {
272+
return p.NestedProps
273+
}
274+
direct := xmlPropGroup{Properties: p.NestedDirectProps}
275+
for i := range p.NestedDirectProps {
276+
direct.Children = append(direct.Children, xmlPropGroupChild{Property: &p.NestedDirectProps[i]})
277+
}
278+
return append(append([]xmlPropGroup(nil), p.NestedProps...), direct)
255279
}
256280

257281
// xmlActionVariable represents <actionVariable key="…" caption="…" type="…"/>.
@@ -455,8 +479,8 @@ func walkPropertyGroup(pg xmlPropGroup, parentCategory string, def *WidgetDefini
455479
}
456480

457481
// Parse nested properties for object-type properties
458-
if p.Type == "object" && len(p.NestedProps) > 0 {
459-
for _, npg := range p.NestedProps {
482+
if p.Type == "object" {
483+
for _, npg := range nestedGroups(p) {
460484
collectNestedProperties(npg, &prop, "")
461485
}
462486
}
@@ -503,6 +527,11 @@ func collectNestedProperties(pg xmlPropGroup, parent *PropertyDef, parentCategor
503527
category = parentCategory
504528
}
505529
for _, p := range pg.Properties {
530+
// A sub-property outside any group names its category itself.
531+
childCategory := category
532+
if childCategory == "" {
533+
childCategory = strings.TrimSpace(p.Category)
534+
}
506535
var allowedTypes []string
507536
for _, at := range p.AttributeTypes {
508537
if at.Name != "" {
@@ -518,7 +547,7 @@ func collectNestedProperties(pg xmlPropGroup, parent *PropertyDef, parentCategor
518547
Type: p.Type,
519548
Caption: p.Caption,
520549
Description: p.Description,
521-
Category: category,
550+
Category: childCategory,
522551
// Mendix pluggable-widget spec: `required` defaults to true when the
523552
// attribute is absent (mxbuild's update-widgets emits Required=true for
524553
// every property that omits required=, e.g. DataGrid2 showContentAs). Only
@@ -542,8 +571,8 @@ func collectNestedProperties(pg xmlPropGroup, parent *PropertyDef, parentCategor
542571
ActionVariables: toActionVariables(p.ActionVariables),
543572
}
544573
// Nested object-type properties can themselves contain object lists.
545-
if p.Type == "object" && len(p.NestedProps) > 0 {
546-
for _, npg := range p.NestedProps {
574+
if p.Type == "object" {
575+
for _, npg := range nestedGroups(p) {
547576
collectNestedProperties(npg, &child, "")
548577
}
549578
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package mpk
4+
5+
import "testing"
6+
7+
// mendixlabs/mxcli#1632: an object property may list its sub-properties directly
8+
// under <properties>, with no <propertyGroup> around them, and give each one its
9+
// category as a <category> element. The Marketplace Calendar's toolbarItems does.
10+
// Only grouped sub-properties were read, so the object came back with no Children,
11+
// its generated ObjectType was nil, and every Calendar failed `mx check` with
12+
// CE0463 until `update-widgets` rewrote the Type.
13+
func TestParse_ObjectPropertyWithDirectSubProperties(t *testing.T) {
14+
const widgetXML = `<?xml version="1.0" encoding="utf-8"?>
15+
<widget id="com.example.Cal" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/">
16+
<name>Cal</name>
17+
<properties>
18+
<propertyGroup caption="General">
19+
<propertyGroup caption="Toolbar">
20+
<property key="toolbarItems" type="object" isList="true" required="false">
21+
<caption>Custom top bar views</caption><description/>
22+
<properties>
23+
<property key="itemType" type="enumeration" defaultValue="month">
24+
<caption>Item</caption>
25+
<category>Appearance</category>
26+
<description/>
27+
<enumerationValues>
28+
<enumerationValue key="day">Day</enumerationValue>
29+
<enumerationValue key="month">Month</enumerationValue>
30+
</enumerationValues>
31+
</property>
32+
<property key="caption" type="textTemplate" required="false">
33+
<caption>Caption</caption><description/>
34+
</property>
35+
</properties>
36+
</property>
37+
<property key="lines" type="object" isList="true">
38+
<caption>Series</caption><description/>
39+
<properties>
40+
<propertyGroup caption="General">
41+
<property key="dataSet" type="enumeration" defaultValue="static">
42+
<caption>Data set</caption><description/>
43+
<enumerationValues><enumerationValue key="static">Single</enumerationValue></enumerationValues>
44+
</property>
45+
</propertyGroup>
46+
</properties>
47+
</property>
48+
</propertyGroup>
49+
</propertyGroup>
50+
</properties>
51+
</widget>`
52+
53+
def := parseWidgetXML(t, widgetXML)
54+
children := map[string][]PropertyDef{}
55+
for _, p := range def.Properties {
56+
children[p.Key] = p.Children
57+
}
58+
59+
type want struct{ key, category string }
60+
check := func(prop string, wants []want) {
61+
t.Helper()
62+
got := children[prop]
63+
if len(got) != len(wants) {
64+
t.Fatalf("%s: %d sub-properties, want %d (%v)", prop, len(got), len(wants), got)
65+
}
66+
for i, w := range wants {
67+
if got[i].Key != w.key || got[i].Category != w.category {
68+
t.Errorf("%s[%d] = {%q, category %q}, want {%q, category %q}",
69+
prop, i, got[i].Key, got[i].Category, w.key, w.category)
70+
}
71+
}
72+
}
73+
// Direct: read in document order, the category from the property's own
74+
// <category> element, none when it declares none.
75+
check("toolbarItems", []want{{"itemType", "Appearance"}, {"caption", ""}})
76+
if got := children["toolbarItems"]; len(got) == 2 {
77+
if len(got[0].EnumValues) != 2 || got[1].Required {
78+
t.Errorf("direct sub-properties lost their attributes: %+v", got)
79+
}
80+
}
81+
// Control: grouped sub-properties keep the group caption as their category.
82+
check("lines", []want{{"dataSet", "General"}})
83+
}
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
3+
package widgets
4+
5+
import (
6+
"archive/zip"
7+
"os"
8+
"path/filepath"
9+
"testing"
10+
11+
"github.com/mendixlabs/mxcli/modelsdk/widgets/mpk"
12+
)
13+
14+
// mendixlabs/mxcli#1632, end to end from the .mpk: the Marketplace Calendar lists
15+
// toolbarItems' sub-properties directly under <properties>. The generated Type
16+
// wrote that object property with ObjectType nil, where mxbuild writes a
17+
// WidgetObjectType holding the sub-property types — CE0463 on every Calendar.
18+
func TestGenerateFromMPK_ObjectPropertyWithDirectSubProperties(t *testing.T) {
19+
const pkgXML = `<?xml version="1.0" encoding="utf-8"?>
20+
<package xmlns="http://www.mendix.com/package/1.0/">
21+
<clientModule name="Cal" version="1.0.0" xmlns="http://www.mendix.com/clientModule/1.0/">
22+
<widgetFiles><widgetFile path="Cal.xml"/></widgetFiles>
23+
</clientModule>
24+
</package>`
25+
const widgetXML = `<?xml version="1.0" encoding="utf-8"?>
26+
<widget id="com.example.Cal" pluginWidget="true" xmlns="http://www.mendix.com/widget/1.0/">
27+
<name>Cal</name>
28+
<properties>
29+
<propertyGroup caption="General">
30+
<property key="toolbarItems" type="object" isList="true" required="false">
31+
<caption>Custom top bar views</caption><description/>
32+
<properties>
33+
<property key="itemType" type="enumeration" defaultValue="month">
34+
<caption>Item</caption>
35+
<category>Appearance</category>
36+
<description/>
37+
<enumerationValues>
38+
<enumerationValue key="day">Day</enumerationValue>
39+
<enumerationValue key="month">Month</enumerationValue>
40+
</enumerationValues>
41+
</property>
42+
<property key="caption" type="textTemplate" required="false">
43+
<caption>Caption</caption><description/>
44+
</property>
45+
</properties>
46+
</property>
47+
</propertyGroup>
48+
</properties>
49+
</widget>`
50+
51+
path := filepath.Join(t.TempDir(), "Cal.mpk")
52+
f, err := os.Create(path)
53+
if err != nil {
54+
t.Fatal(err)
55+
}
56+
zw := zip.NewWriter(f)
57+
for name, body := range map[string]string{"package.xml": pkgXML, "Cal.xml": widgetXML} {
58+
w, err := zw.Create(name)
59+
if err != nil {
60+
t.Fatal(err)
61+
}
62+
if _, err := w.Write([]byte(body)); err != nil {
63+
t.Fatal(err)
64+
}
65+
}
66+
if err := zw.Close(); err != nil {
67+
t.Fatal(err)
68+
}
69+
f.Close()
70+
71+
def, err := mpk.ParseMPK(path)
72+
if err != nil {
73+
t.Fatal(err)
74+
}
75+
ResetPlaceholderCounter()
76+
tmpl := GenerateFromMPK(def)
77+
78+
var toolbar map[string]any
79+
for _, pt := range tmpl.Type["ObjectType"].(map[string]any)["PropertyTypes"].([]any) {
80+
if m, ok := pt.(map[string]any); ok && m["PropertyKey"] == "toolbarItems" {
81+
toolbar = m
82+
}
83+
}
84+
if toolbar == nil {
85+
t.Fatal("toolbarItems PropertyType missing")
86+
}
87+
objType, _ := toolbar["ValueType"].(map[string]any)["ObjectType"].(map[string]any)
88+
if objType == nil {
89+
t.Fatal("toolbarItems ValueType.ObjectType is nil; mxbuild writes a WidgetObjectType with its sub-property types")
90+
}
91+
var keys, cats []string
92+
for _, pt := range objType["PropertyTypes"].([]any) {
93+
if m, ok := pt.(map[string]any); ok {
94+
keys = append(keys, m["PropertyKey"].(string))
95+
cats = append(cats, m["Category"].(string))
96+
}
97+
}
98+
if len(keys) != 2 || keys[0] != "itemType" || keys[1] != "caption" {
99+
t.Fatalf("sub-property types = %v, want [itemType caption]", keys)
100+
}
101+
// mxbuild writes Category "Appearance" for the Calendar's itemType, from its
102+
// <category> element. (Every sub-property of the real Calendar declares one.)
103+
if cats[0] != "Appearance" {
104+
t.Errorf("itemType Category = %q, want %q", cats[0], "Appearance")
105+
}
106+
}

0 commit comments

Comments
 (0)