Skip to content

Commit 0ecde78

Browse files
authored
Merge pull request #577 from ako/claude/fix-552-list-widget-row-action
fix(pages): judge a list widget's own row action in the context it creates
2 parents e739fd2 + fa289cc commit 0ecde78

5 files changed

Lines changed: 205 additions & 2 deletions

File tree

‎.claude/skills/fix-issue/findings/mdl-executor.jsonl‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,3 +661,4 @@
661661
{"area":"mdl/linter","date":"2026-09-20","symptom":"mxcli happily authors `staticimage`/`dynamicimage` with nothing warning the author, and #518/#538 had just made both MORE capable (Image:, DataSource:, DefaultImage:, thumbnail, enlarge all newly reachable). The only signal that these widgets do not work was CE0582 at the far end of a build. Separately, three places in code comments and user-facing help claimed the deprecation was 'Mendix 11's React client'","cause":"Two things. (1) No validator or lint rule mentioned either widget (measured: `grep -rln deprecat mdl/executor/validate*.go` matched only an unrelated test), so the deprecation lived entirely in prose. (2) The version claim was inherited from a pre-existing comment and repeated without checking the doc: docs.mendix.com/refguide/image-viewer/ says the React client was added in **10.7**, so CE0582 fires on 10.7+ wherever that client is enabled, not only on 11","file":"`mdl/linter/rules/legacy_image_widget.go` (new, MPR012) + registration in `mdl/executor/cmd_lint.go` (x2) and `cmd/mxcli/cmd_lint.go`; wording in `mdl/backend/modelsdk/widget_write_legacy_gaps.go`, `.claude/skills/mendix/create-page/reference/widgets.md`, `cmd/mxcli/syntax/features_page.go`; table row in `.claude/commands/mendix/lint.md`","insight":"**A deprecation warning belongs in `lint`, not in `check`.** `check` validates a script, and `describe page` -> `exec` of a legacy page is a legitimate lossless operation — a check warning would fire on correct work every time, which is the noise trap MDL-WIDGET23's own history records. `lint` audits the project, where 'this page holds a widget your client cannot render' is wanted once. **The marketplace exclusion came free and is the control worth measuring**: `ctx.Widgets()` filters any module with a Source (notPlatformModule), so the rule never fires on the Studio Pro static images a blank app inherits from FeedbackModule — content the reader cannot fix and an update would replace. Measured: 8 legacy image widgets in the project, 7 indexed by the catalog, 5 in the user's own module, and lint reported exactly those 5. **A deny-list of two, never an allow-list**: the one widget such a rule must never fire on is the pluggable Image, i.e. the replacement it recommends. **'Deprecated in version X' needs the vendor doc, not the previous comment** — this repo had carried 'Mendix 11' for as long as the widgets had been written, and one fetch of the reference guide moved it to 10.7. A version boundary copied from a sibling comment is the same class of error as a floor copied from a proposal's sample output (mendixlabs/mxcli#1121)","refs":["mendixlabs/mxcli#1057"],"ce":["CE0582"],"rules":["MPR012"]}
662662
{"area": "mdl/backend/pagemutator", "date": "2026-09-20", "symptom": "`alter page … { set DataSource = DATABASE Mod.Entity on dvCust; }` passes `check`, prints `Altered page …` with exit 0, and leaves the DataView with no datasource: `describe page` renders `dataview dvCust {` with the property gone, and the only other signal is CE7007 at `mx check`", "cause": "`serializeDataSourceBson` mapped every `*pages.DatabaseSource` to a `Forms$DataViewSource` — the *context* source — with the entity in `EntityRef` and `SourceVariable` left null. A DATABASE source has no single stored shape: the widget holding it decides (`Forms$ListViewXPathSource` on a list view, `CustomWidgets$CustomWidgetXPathSource` on a pluggable widget, `Forms$GridXPathSource` on a grid), and a DATA VIEW has no database form at all — which is why CREATE PAGE's `dataViewSourceToGen` already refused that pairing while SET wrote it silently", "file": "`mdl/backend/pagemutator/mutator.go` (`SetWidgetDataSource`, new `databaseSourceRefusal`, `serializeDataSourceBson`)", "insight": "**The \"gone entirely\" in the report was DESCRIBE, not the document.** The DataSource was present and well-formed BSON; `parseContextSource` returns nil for a `Forms$DataViewSource` with no `SourceVariable`, so the reader rendered nothing. Chasing a deleted property would have been the wrong hunt — diff the stored BSON before believing a describe-shaped symptom. **The refusal belongs in the mutator, not the validator**: `validateAlterSetProperties` dry-runs the real setter against a `pagemutator.Probe()` copy, so one refusal makes `check -p --references` and `exec` agree by construction; a second copy of the rule in the validator is the duplicate-resolver drift CLAUDE.md warns about. **Refusing beat rebuilding the shapes here** — writing ListViewXPathSource in raw BSON would duplicate `listViewSourceToGen` in a second currency, and REPLACE already reaches the real builder. **Two remedies, not one**: on a data view `use REPLACE` is a dead end (CREATE PAGE refuses it too), so the message names the sources a data view can take; on a list view REPLACE genuinely works, so it names REPLACE. Getting that backwards sends the author in a circle. **Same generalisable shape as #855/#1101**: when SET and REPLACE express different vocabularies for one property, SET is a whitelist extended one bug report at a time. **`make check-mdl` runs `mxcli check` WITHOUT `-p`**, so a document-dependent refusal cannot be a `.fail.mdl` — it would be reported as a negative test that unexpectedly passed. Write the passing shape and comment the refused statements, as #1063 does. Measured on two copies of a real 11.13.0 app: faulty → `Check passed!`, exit 0, `mx check` 1 error CE7007 at Data view 'dvCust'; fixed → both refuse with exit 1, datasource unchanged, `mx check` 0 errors. Tests `mdl/backend/pagemutator/mutator_datasource_test.go`, `mdl/executor/validate_alter_set_test.go`; example `mdl-examples/bug-tests/1032-alter-page-set-database-datasource.mdl`. upstream #1032", "refs": ["#855", "#1032"], "ce": ["CE7007"]}
663663
{"area": "mdl/executor", "date": "2026-09-20", "symptom": "`describe page` → `exec` over a **Studio Pro-authored** page silently drops six things, `mx check` 0 errors throughout. The one that matters: `IsPasswordBox True → False` — a **password field round-trips into a plaintext text box**, and describe → rename → exec is mxcli's copy operation. Also `Validation.Expression` blanked, a DataView's `ReadOnlyStyle Text → Control`, `PopupCloseAction` wiped, and two typed-array markers", "cause": "Four different causes behind one symptom, which is why triage came first: (1) IsPasswordBox — model and writer carried it, nothing parsed it, nothing emitted it; (2) Validation — `widgetValidationToGen()` wrote a DEFAULT EMPTY Forms$WidgetValidation over whatever was stored, on five widget types; (3) ReadOnlyStyle — wired for CheckBox only, and a DataView's draws no MDL-WIDGET07 warning because `staticWidgetKnownProps` is deliberately a union across widget types; (4) PopupCloseAction — `pageToGen` wrote \"\" unconditionally. Plus ParameterMappings/OutputMappings markers", "file": "`mdl/executor/cmd_pages_describe_parse.go` + `_output.go` (extract/emit), `cmd_pages_builder_v3_widgets.go` (consume), `cmd_pages_builder_v3.go`, `mdl/visitor/visitor_page_v3.go`, `mdl/ast/ast_page_v3.go`, `sdk/pages/*`, `mdl/backend/modelsdk/widget_write.go` + `page_write.go`, `mdl/executor/validate_widgets.go` (describe vocabulary)", "insight": "**Triage the layer before writing anything** — describer / grammar / builder have different fixes and this one issue had all three. The quickest probe is to run the property through `mxcli check`: MDL-WIDGET07 names an unrecognised one, and *silence is not acceptance* — the known-props list is a union across widget types, so a DataView's ReadOnlyStyle passed check and was dropped anyway. **Emit an expression QUOTED, not bracketed**: `[...]` is the XPath-constraint spelling and `propertyValueV3` parses it as an ARRAY, so `GetStringProp` yields \"\" — the emitter's own unit test was green while the real round trip still lost the value (storage form is not input form). **Measure the default before keeping it**: a DataView's ReadOnlyStyle is Control on 47 of 56, never Inherit, so the 'obvious' Inherit that every other input widget uses would have been wrong. Markers likewise measured, not assumed: ParameterMappings is marker 2 on 220 of 220 lists in every parent type, OutputMappings present on 91 of 91 — and an EMPTY list needs `MandatoryListMarkers` since `RegisterListMarker` keys on a child that is not there. Result 17 → 9 differences, the 9 being ako/mxcli#549", "refs": ["#550", "#541", "#549", "#490"]}
664+
{"area": "mdl/executor", "date": "2026-09-20", "symptom": "MDL-PAGEARG01 refused a list widget's OWN row action: `datagrid dg (DataSource: DATABASE M.E, onClick: SHOW_PAGE M.Edit(E: $currentObject))` was rejected at `check` with \"widget `dg` is not inside a data view, list view or grid row\" \u2014 and since exec refuses a script whose check errors, the slice could not be applied at all. On a `listview` the message contradicted itself. mxbuild 11.14.0 accepts the stored pages at 0 errors.", "cause": "The #1029 guard judged EVERY widget's own action in the context its PARENT supplies: `argContextForSubtreeOf` returns the parent context for a childless widget and `validate_widgets.go` passed the inherited `argCtx` to `validateShowPageArguments`. Right for a button, wrong for the widget that ESTABLISHES the context \u2014 a list widget's onClick is row-scoped, so the row it renders is the context object. Added `argContextForOwnAction`: a widget that binds a source of its own supplies the context for its own action; a source in a shape the pass cannot read (the bare-entity shorthand) degrades to UNKNOWN so the guard stands down rather than refusing what it cannot prove is discarded.", "file": "`mdl/executor/cmd_pages_showpage_args.go` (argContextForOwnAction, argContextForSubtreeOf), `mdl/executor/validate_widgets.go`", "insight": "**A false refusal costs more than a missing rule now that exec refuses on a check error** \u2014 the blast radius is 'this project cannot be built with this mxcli', not 'a warning is noisy'. Two things would have caught it before release: judging the rule against the widget kinds it NAMES in its own message (the listview refusal reads 'lvA is not inside a \u2026 list view'), and running it against mxbuild rather than against intuition. The mxbuild run paid for itself twice: it also showed that `DataSource: M.E` (bare-entity shorthand) on a datagrid is silently dropped, so that case is CE0488 + a REAL CE1571 \u2014 the stand-down is still correct, but the shorthand case must not be written into a bug test as mxbuild-clean (#576). Control the fix with the widget kinds STILL refused (a foreign variable, a sibling button beside the grid), or it is indistinguishable from deleting the rule.", "refs": ["#552", "#576", "mendixlabs/mxcli#1029", "#939"]}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
-- ako/mxcli#552 — MDL-PAGEARG01 refused a list widget's OWN row action.
2+
--
3+
-- `onClick` on a data grid, list view or gallery fires per row, so the row the
4+
-- widget renders IS the context object. The #1029 guard judged every widget's
5+
-- own action in the context its PARENT supplies, so each statement below was
6+
-- refused at `check` — and, since exec refuses a script whose check errors,
7+
-- could not be applied at all. mxbuild accepts the stored pages at 0 errors.
8+
--
9+
-- On a list view the refusal contradicted itself: "widget `lvCars` is not
10+
-- inside a data view, list view or grid row".
11+
--
12+
-- This file is a CHECK-time regression: `mxcli check` must report 0 errors.
13+
-- The control lives beside it — 1029-showpage-arg-without-context.fail.mdl is
14+
-- the contextless page-level button, which must STILL be refused.
15+
16+
create module Mod;
17+
18+
create entity Mod.Car (
19+
Name: String(100)
20+
);
21+
22+
create page Mod.Detail (Title: 'Car', Layout: Atlas_Core.Atlas_Default, Params: { $Car: Mod.Car }) {
23+
dataview dvCar (DataSource: $Car) {
24+
textbox tbName (Label: 'Name', Attribute: Name)
25+
}
26+
};
27+
28+
-- A data grid's own onClick: the clicked row is the context object.
29+
create page Mod.Grid (Title: 'Cars', Layout: Atlas_Core.Atlas_Default) {
30+
datagrid dgCars (
31+
DataSource: DATABASE Mod.Car,
32+
onClick: SHOW_PAGE Mod.Detail(Car: $currentObject)
33+
) {
34+
column colName (Caption: 'Name', Attribute: Name)
35+
}
36+
};
37+
38+
-- A list view's own onClick, same rule.
39+
create page Mod.List (Title: 'Cars', Layout: Atlas_Core.Atlas_Default) {
40+
listview lvCars (
41+
DataSource: DATABASE Mod.Car,
42+
onClick: SHOW_PAGE Mod.Detail(Car: $currentObject)
43+
) {
44+
dynamictext dtName (Content: '{1}', ContentParams: [{1} = Name])
45+
}
46+
};
47+
48+
-- NOT a case for this file: the bare-entity shorthand `DataSource: Mod.Car` on a
49+
-- data grid is SILENTLY DROPPED (the stored widget has no data source at all),
50+
-- so mxbuild reports CE0488 and then a real CE1571. The guard still stands down
51+
-- on it — it refuses only what it can prove is discarded, and a source it cannot
52+
-- read is unknown, not absent — but that case belongs to the shorthand bug, not
53+
-- here. Measured on mxbuild 11.14.0; see ako/mxcli#576.

‎mdl/executor/cmd_pages_showpage_args.go‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,63 @@ func argContextForChildren(w *ast.WidgetV3, parent pageArgContext) pageArgContex
108108
return parent
109109
}
110110

111+
// argContextForOwnAction is the context a widget's OWN action is judged in.
112+
//
113+
// A button's action runs in the context its parent supplies. A list widget's does
114+
// not: `onClick` on a data grid, list view or gallery fires PER ROW, and the row
115+
// it renders is the context object — so a widget that binds a source of its own
116+
// supplies the context for its own action. Judging it in the parent's context
117+
// refused `datagrid dg (DataSource: DATABASE M.E, onClick: SHOW_PAGE M.Edit(E:
118+
// $currentObject))` against an mxbuild that accepts it at 0 errors, and on a list
119+
// view the refusal contradicted its own wording (ako/mxcli#552).
120+
//
121+
// `Action:` and `onClick:` are aliases that both land on Properties["Action"], so
122+
// this covers every spelling of a widget's own action.
123+
func argContextForOwnAction(w *ast.WidgetV3, parent pageArgContext) pageArgContext {
124+
if w == nil {
125+
return parent
126+
}
127+
if ds := w.GetDataSource(); ds != nil {
128+
// The entity is only used to word a refusal; the executor's builder
129+
// overwrites this with one that carries it.
130+
return enteringDataWidget(ds, "")
131+
}
132+
if bindsDataInAnUnreadableShape(w) {
133+
// The widget plainly binds data, so a context object EXISTS — but this
134+
// pass cannot say what it is called. Unknown, not absent, and the guard
135+
// stands down exactly as it does for ALTER PAGE. The bare-entity
136+
// shorthand `datagrid dg (DataSource: M.E)` is this case.
137+
return pageArgContext{}
138+
}
139+
return parent
140+
}
141+
142+
// bindsDataInAnUnreadableShape reports whether w names a data source this pass
143+
// cannot parse into a *ast.DataSourceV3 — the bare-entity shorthand, or a
144+
// pluggable widget naming its source under its own key.
145+
func bindsDataInAnUnreadableShape(w *ast.WidgetV3) bool {
146+
for name, v := range w.Properties {
147+
if !strings.EqualFold(name, "DataSource") {
148+
continue
149+
}
150+
if _, parsed := v.(*ast.DataSourceV3); !parsed && v != nil {
151+
return true
152+
}
153+
}
154+
return false
155+
}
156+
111157
// argContextForSubtreeOf is argContextForChildren for the executor's builder,
112158
// which builds a widget AND its children in one call. A widget with no children
113159
// carries nothing but its own action, and that action is judged in the context
114160
// its parent supplies — degrading there would stand the guard down on exactly the
115-
// page-level button #1029 is about.
161+
// page-level button #1029 is about. A data-bound widget is the exception, and the
162+
// reason is argContextForOwnAction's: its own action is row-scoped, so it needs
163+
// the context it creates whether or not it has children to give it to.
116164
func argContextForSubtreeOf(w *ast.WidgetV3, parent pageArgContext) pageArgContext {
165+
if own := argContextForOwnAction(w, parent); own != parent {
166+
return own
167+
}
117168
if len(w.Children) == 0 {
118169
return parent
119170
}

‎mdl/executor/cmd_pages_showpage_args_test.go‎

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,99 @@ func TestValidateShowPageArguments_AlterPageStandsDown(t *testing.T) {
219219
}
220220
}
221221
}
222+
223+
// ako/mxcli#552: a list widget's OWN action is row-scoped, so the row it renders
224+
// IS the context object. The #1029 guard judged every widget's own action in the
225+
// context its PARENT supplies, which is right for a button and wrong for the
226+
// widget that establishes the context — it refused
227+
//
228+
// datagrid dgRequests (DataSource: DATABASE M.ServiceRequest,
229+
// onClick: SHOW_PAGE M.Edit(ServiceRequest: $currentObject))
230+
//
231+
// with "widget `dgRequests` is not inside a data view, list view or grid row",
232+
// while mxbuild accepts the stored page at 0 errors. On a `listview` the message
233+
// contradicted itself outright.
234+
//
235+
// `onClick:` and `Action:` are aliases that both land on Properties["Action"]
236+
// (see validate_widget_action_slot.go), so one shape covers both spellings.
237+
func TestValidateShowPageArguments_ListWidgetOwnRowAction(t *testing.T) {
238+
registry := LoadWidgetRegistry("")
239+
if registry == nil {
240+
t.Fatal("LoadWidgetRegistry returned nil")
241+
}
242+
243+
rowAction := func(kind string, source any, arg string) *ast.WidgetV3 {
244+
return &ast.WidgetV3{
245+
Type: kind,
246+
Name: "w1",
247+
Properties: map[string]any{
248+
"DataSource": source,
249+
"Action": &ast.ActionV3{
250+
Type: "showPage",
251+
Target: "Mod.Detail",
252+
Args: []ast.FlowArgV3{{Name: "Car", Value: arg}},
253+
},
254+
},
255+
}
256+
}
257+
database := &ast.DataSourceV3{Type: "database", Reference: "Mod.Car"}
258+
259+
hits := func(w *ast.WidgetV3) []string {
260+
var msgs []string
261+
for _, v := range validateWidgetTree([]*ast.WidgetV3{w}, registry, "page Mod.P") {
262+
if v.RuleID == "MDL-PAGEARG01" {
263+
msgs = append(msgs, v.Message)
264+
}
265+
}
266+
return msgs
267+
}
268+
269+
// The row object, under either spelling, on each widget kind that renders rows.
270+
for _, kind := range []string{"datagrid", "listview", "gallery"} {
271+
t.Run(kind+"/$currentObject", func(t *testing.T) {
272+
if got := hits(rowAction(kind, database, "$currentObject")); len(got) != 0 {
273+
t.Errorf("a %s's own row action was refused — mxbuild accepts it at 0 errors: %s", kind, got[0])
274+
}
275+
})
276+
}
277+
278+
// The bare-entity shorthand leaves a plain string rather than a parsed source,
279+
// so the entity is unreadable — but the widget plainly binds data, and the
280+
// guard's own doctrine is that it refuses only what it can PROVE is discarded.
281+
t.Run("bare-entity shorthand stands the guard down", func(t *testing.T) {
282+
if got := hits(rowAction("datagrid", "Mod.Car", "$currentObject")); len(got) != 0 {
283+
t.Errorf("shorthand source was refused: %s", got[0])
284+
}
285+
})
286+
287+
// Controls. Without these the fix is indistinguishable from deleting the rule.
288+
t.Run("control: a foreign variable on a row action is still refused", func(t *testing.T) {
289+
if got := hits(rowAction("datagrid", database, "$Other")); len(got) != 1 {
290+
t.Errorf("MDL-PAGEARG01 violations = %d, want 1 — a database row source names no $Other", len(got))
291+
}
292+
})
293+
t.Run("control: #1029's page-level button is still refused", func(t *testing.T) {
294+
var n int
295+
for _, v := range validateWidgetTree([]*ast.WidgetV3{showPageButton("$SomeRef")}, registry, "page Mod.P") {
296+
if v.RuleID == "MDL-PAGEARG01" {
297+
n++
298+
}
299+
}
300+
if n != 1 {
301+
t.Errorf("MDL-PAGEARG01 violations on a contextless button = %d, want 1", n)
302+
}
303+
})
304+
t.Run("control: a button beside the grid, not in it, is still refused", func(t *testing.T) {
305+
grid := rowAction("datagrid", database, "$currentObject")
306+
tree := []*ast.WidgetV3{{Type: "container", Name: "c1", Children: []*ast.WidgetV3{grid, showPageButton("$currentObject")}}}
307+
var n int
308+
for _, v := range validateWidgetTree(tree, registry, "page Mod.P") {
309+
if v.RuleID == "MDL-PAGEARG01" {
310+
n++
311+
}
312+
}
313+
if n != 1 {
314+
t.Errorf("MDL-PAGEARG01 violations = %d, want 1 — the grid's own action is fine, the sibling button is not", n)
315+
}
316+
})
317+
}

0 commit comments

Comments
 (0)