Skip to content

Commit f0488ce

Browse files
committed
test(widget): derive fixture widget definitions instead of reading gitignored ones
The three MDL-WIDGET27 tests added in d614807 passed locally and failed in CI on the same commit: two got the fallback remedy instead of the container keyword, the third found 0 violations. They resolved the widget through LoadWidgetRegistry(fixtureProject(t)), which reads .def.json files from testdata/expr-checker/.mxcli/widgets/. That directory is GITIGNORED — the definitions are derived, not tracked — so they exist for any developer who has run `mxcli widget docs` against the fixture (I generated them earlier in the same session, investigating the issue) and never exist on the runner. With no definition, containerKeyword returns "" and the two definition-dependent branches degrade exactly as designed. fixtureProjectWithDefs copies the fixture to a temp dir, removes any .mxcli the developer's tree carries, and derives the definitions from the tracked .mpk files with RefreshWidgetDefinitions. Local and CI now see identical inputs, and the generated files stay out of the fixture other tests copy. Also tightens the #999 assertion, which is why the suite did not catch this: strings.Contains(msg, "attribute") on a widget whose property is named `attributes` is satisfied by the property name alone, so it passed with no definition loaded. It now asserts the remedy shape, which only a resolved definition produces. Reproduced by moving .mxcli aside — same three failures, same messages. Control: with the derivation stubbed, all FOUR fail, where before only the three new ones did. Restored, full suite green. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KTdvGwVewkdgNQGDCxpQPZ
1 parent 4862fe5 commit f0488ce

2 files changed

Lines changed: 38 additions & 3 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
@@ -606,3 +606,4 @@
606606
{"area": "mdl/executor", "date": "2026-09-13", "symptom": "A boundary event path written from MDL fails the build with CE0105 'Call microflow cannot be the last object of a flow, it should end with a jump or end activity' (interrupting), or builds at 0 errors and the runtime refuses to start: 'Expected the flow to end with an end event' (non-interrupting). After the fix, `create or modify` of the same workflow was refused by the dropped-construct guard", "cause": "Mendix ends every boundary event path with `EndOfBoundaryEventPathActivity`; mxcli never wrote one, and MDL has no end statement. The rewrite guard then counted `$Type`s containing 'BoundaryEvent', which includes the marker, so a stored workflow with one event counted two", "file": "`sdk/workflows/workflow.go` (`EndBoundaryEventPath`), `mdl/executor/cmd_workflows_write.go` (`buildBoundaryEvents`), `mdl/backend/wfmutator/mutator.go` + `mdl/backend/mcp/workflow.go` (`InsertBoundaryEvent`), `mdl/executor/validate_workflow_rewrite.go` (`countRawBoundaryEvents`)", "insight": "**Same class as the parallel-split marker: a Studio Pro terminal marker that no MDL statement spells.** Grep the writers for every `EndOf*` type the reader knows before assuming one is the only one. The guard miscount was only visible by re-running the fixed script against the fixed workflow \u2014 a substring match on `$Type` is wrong the moment a sibling type shares the stem; match the suffix, and keep a control asserting the substring count so the test says why", "fix": "Append the marker unless the path ends in a jump or end-of-workflow (CE6692 otherwise); count boundary events by `strings.HasSuffix($Type, \"BoundaryEvent\")`"}
607607
{"area": "mdl/executor", "date": "2026-09-13", "symptom": "A workflow with `boundary event timer '\u2026'` (no interrupting / non interrupting) passes check and builds at 0 errors; the runtime then fails to start: `Class 'Workflows$TimerBoundaryEvent' could not be found`", "cause": "The bare form maps to `Workflows$TimerBoundaryEvent`, which exists in no cached 11.x runtime (only Interrupting/NonInterruptingTimerBoundaryEvent). mxbuild tolerates the unknown type. It was the documented syntax example", "file": "`mdl/executor/validate_workflow_refs.go` (`bareTimerBoundaryEventErrors`, MDL-WF07), `cmd/mxcli/syntax/features_workflow.go`", "insight": "**A type mxbuild accepts is not a type the runtime has.** Found only because a verification boot of an unrelated fix loaded it. When a grammar has a default branch that maps to a storage type, check that type against the runtime's class list, not against `mx check`", "fix": "Refuse the bare form on 11+ at check and exec, CREATE and every ALTER op that can carry a boundary event; update syntax help, skill table and the ako/mxcli#415 bug-test script to name the kind"}
608608
{"area": "mdl/executor", "date": "2026-09-13", "symptom": "A view entity whose association column is also declared as an attribute (`MeterRef: Trends.Meter` or `MeterRef: Trends.Meter.ID` beside `select m.ID as MeterRef`) passes `mxcli check`; `check -p` says 'OQL select has 1 columns but 2 attributes declared'; exec writes `Enumeration(Trends.Meter)` and mx check reports CE1613, or throws 'An error occurred when trying to set the Enumeration property' for the three-part form", "cause": "A bare qualified name parses as TypeEnumeration (the entity/enum ambiguity), and execCreateViewEntity converted it with convertDataType without asking what it names. The alias-to-attribute alignment skips association columns, so the declared attribute had no column and was compared against the next one", "file": "`mdl/executor/oql_view_associations.go` (`ValidateViewAttributeDeclarations` MDL080, `viewAttributeEntityTypeErrors`), `mdl/executor/cmd_entities.go` (`execCreateViewEntity`), `mdl/executor/validate.go`, `mdl/executor/validate_program.go`, `cmd/mxcli/lsp_diagnostics.go`", "insight": "**The TypeEnumeration/TypeEntity ambiguity has a consumer wherever a data type becomes a stored type, and view entity attributes were one nobody had listed.** Split the refusal by what it needs: an association column's alias and a three-part name are decidable from the script, so they belong in the no-project phase that exec's pre-check also runs; entity-vs-enum needs the project, so it goes in check -p AND the handler, because exec --no-check skips both phases. Verify the handler refusal by counting changed files, not by the error text", "fix": "Refuse in ValidateProgram/LSP (MDL080) and at the top of execCreateViewEntity before any backend call; report an attribute once"}
609+
{"area": "mdl/executor", "date": "2026-09-13", "symptom": "Three new MDL-WIDGET27 tests passed locally and failed in CI on the same commit: two reported the fallback remedy (\"move the entries into the widget body as container blocks\") instead of naming the container keyword, and the third found 0 violations where it wanted 1", "cause": "The tests resolved the widget through `LoadWidgetRegistry(fixtureProject(t))`, which reads `.def.json` files from `testdata/expr-checker/.mxcli/widgets/`. That directory is GITIGNORED — the definitions are derived, not tracked — so they exist for any developer who has ever run `mxcli widget docs` against the fixture (I generated them earlier in the same session, while investigating) and never exist on the runner. With no definition, `containerKeyword` returns \"\" and the two definition-dependent branches degrade exactly as designed: fallback wording, and silence for the scalar case", "file": "`mdl/executor/validate_widget_object_property_test.go` (`fixtureProjectWithDefs`)", "insight": "**A gitignored fixture makes a test environment-dependent in the one direction nobody checks** — the developer's tree is a superset of the runner's, so the test is green exactly where it is not being tested. The fix is to DERIVE the artifact from tracked inputs inside the test (`RefreshWidgetDefinitions` over the fixture's tracked `.mpk` files, into a temp copy, after removing any `.mxcli` the developer's tree carries), so local and CI see identical inputs. Reproduce by moving the gitignored directory aside before believing any diagnosis. **The sibling lesson is why this was not caught by the existing suite**: #999's test asserted `strings.Contains(msg, \"attribute\")` on a widget whose property is named `attributes`, so the property name alone satisfied it and the assertion passed with NO definition loaded — a substring assertion whose needle is a substring of the data it is meant to distinguish from proves nothing. Tightened to the remedy shape (`` `attribute <name> (…)` blocks ``) and verified with the derivation stubbed: all four then fail, where before only the three new ones did", "refs": []}

‎mdl/executor/validate_widget_object_property_test.go‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
package executor
44

55
import (
6+
"os"
7+
"path/filepath"
68
"strings"
79
"testing"
810

@@ -11,13 +13,41 @@ import (
1113
"github.com/mendixlabs/mxcli/mdl/visitor"
1214
)
1315

16+
// fixtureProjectWithDefs copies the fixture to a temp dir and DERIVES its widget
17+
// definitions from the tracked `.mpk` files.
18+
//
19+
// `testdata/expr-checker/.mxcli/` is gitignored: the `.def.json` files are
20+
// generated, and a developer who has ever run `mxcli widget docs` against the
21+
// fixture has them while CI never does. Reading them ambiently makes a test pass
22+
// locally and fail on the runner — which is exactly how the three tests below
23+
// first shipped red. Deriving them here depends only on tracked inputs, and the
24+
// copy keeps the generated files out of the fixture other tests copy.
25+
func fixtureProjectWithDefs(t *testing.T) string {
26+
t.Helper()
27+
src := filepath.Dir(fixtureProject(t))
28+
dst := t.TempDir()
29+
if err := os.CopyFS(dst, os.DirFS(src)); err != nil {
30+
t.Fatalf("copy fixture: %v", err)
31+
}
32+
// Start from no definitions whatever the developer's tree holds, so the
33+
// test sees the same inputs here and on the runner.
34+
if err := os.RemoveAll(filepath.Join(dst, ".mxcli")); err != nil {
35+
t.Fatalf("clear derived definitions: %v", err)
36+
}
37+
proj := filepath.Join(dst, "minimal.mpr")
38+
if _, err := RefreshWidgetDefinitions(proj, true, nil); err != nil {
39+
t.Fatalf("derive widget definitions from the tracked .mpk files: %v", err)
40+
}
41+
return proj
42+
}
43+
1444
func widget27(t *testing.T, src string) []linter.Violation {
1545
t.Helper()
1646
prog, errs := visitor.Build(src)
1747
if len(errs) > 0 {
1848
t.Fatalf("parsing: %v", errs)
1949
}
20-
registry := LoadWidgetRegistry(fixtureProject(t))
50+
registry := LoadWidgetRegistry(fixtureProjectWithDefs(t))
2151
if registry == nil {
2252
t.Fatal("no registry")
2353
}
@@ -57,8 +87,12 @@ func TestObjectEntryProperty_IsReported(t *testing.T) {
5787
"page and discard the entries, which is the bug", got[0].Severity)
5888
}
5989
// The message has to name the container keyword, or it says "wrong" without
60-
// saying what right looks like.
61-
if !strings.Contains(got[0].Message, "attribute") {
90+
// saying what right looks like. Assert the KEYWORD IN ITS REMEDY, not a bare
91+
// "attribute": the property is called `attributes`, so a substring check for
92+
// "attribute" is satisfied by the property name and passes with no definition
93+
// loaded at all — which is how the definition-dependent tests below shipped
94+
// green locally and red in CI.
95+
if !strings.Contains(got[0].Message, "`attribute <name> (…)` blocks") {
6296
t.Errorf("message does not name the container keyword: %q", got[0].Message)
6397
}
6498
if !strings.Contains(got[0].Message, "attributes") {

0 commit comments

Comments
 (0)