Commit edc4fa9
fix: stabilize MDL roundtrip and integration flows
Four independent stability fixes surfaced together while chasing a green
roundtrip suite. They touch different layers but are bundled here because
they all gate on the same test run — splitting would require duplicated
test fixtures across PRs.
sdk/mpr — FindOrCreate mapping roundtrip:
Import/export mappings store "FindOrCreate" in BSON as a *pair* of
fields: `ObjectHandling=Find` plus `ObjectHandlingBackup=Create`. The
parser previously copied `ObjectHandling` verbatim (yielding just
"Find"), and the export writer hardcoded `ObjectHandlingBackup=Create`
regardless of the primary mode.
- `parser_import_mapping.go` now recognises the `Find + Create` pair
and promotes it to the synthetic `FindOrCreate` value the domain
model uses elsewhere.
- `writer_export_mapping.go` echoes the actual `ObjectHandling`
instead of forcing "Create"; misuse produced CE6702 on describe +
re-execute cycles.
- `writer_import_mapping.go` inverts the split symmetrically: if the
model says `FindOrCreate`, serialise as `Find` + `Create` so Studio
Pro can load the mapping.
Added parser/writer tests cover both halves and a matching fixture
(`RestTest.PetRecord`) was added to `06-rest-client-examples.mdl`
so the mapping has a real entity to bind to; this lets
`roundtrip_doctype_test.go` drop CE6702 from the known-errors list.
mdl/executor — DROP + CREATE OR REPLACE preserves UnitID:
When a script ran `DROP MICROFLOW X; CREATE OR MODIFY MICROFLOW X ...`
in the same session, the executor deleted the Unit row and inserted
a new one with a fresh UUID. Studio Pro treats the new UnitID as an
unrelated document and rejects the file with ".mpr does not look like
a Mendix Studio Pro project".
- `executor.go` adds a `droppedMicroflows` cache on `executorCache`
keyed by qualified name, plus `rememberDroppedMicroflow` /
`consumeDroppedMicroflow` helpers.
- `cmd_microflows_drop.go` records the UnitID, ContainerID, and
AllowedModuleRoles before calling `DeleteMicroflow`.
- `cmd_microflows_create.go` consumes the remembered entry when the
qualified name matches, reusing the original UnitID (and
ContainerID when no new folder is given) so the rewrite looks like
an in-place update from the file's perspective.
- Mock regression test
`TestDropThenCreatePreservesMicroflowUnitID` asserts the reused
UnitID and preserved access roles.
mdl/executor — default document access roles:
Fresh `CREATE MICROFLOW` / `CREATE PAGE` on a module with no module
roles tripped CE0148 ("document has no access for any role"). Rather
than leaving every script author to define roles by hand, auto-
provision a minimal `User` role on modules that currently have none,
and stamp it onto new pages/microflows.
- `cmd_security_defaults.go` (new) adds `defaultDocumentAccessRoles`,
`remapDocumentAccessRoles` (cross-module MOVE), `documentRoleStrings`,
`cloneRoleIDs`, and `pruneInvalidUserRoles`. The auto-created role
carries a fixed description (`autoDocumentRoleDescription`) so
`CREATE MODULE ROLE User` on the same module is treated as a no-op
rather than CE0112 "already exists".
- `cmd_microflows_create.go` and `cmd_pages_create_v3.go` stamp the
default on new units and preserve existing roles across
`OR REPLACE` / `OR MODIFY`.
- `cmd_move.go` remaps access roles across cross-module moves using
the target module's role names (falling back to the default role
when the target has none).
- `cmd_modules.go` and `cmd_security_write.go` call
`pruneInvalidUserRoles` after DROP MODULE / DROP MODULE ROLE so
orphaned user roles don't trip CE0157.
- `cmd_microflows_builder.go` — `registerResultVariableType(nil)`
now clears stale entity typing and marks the variable as declared
with type `Unknown`, instead of leaving the variable un-tracked,
so subsequent CHANGE/attribute access still resolves. Covered by
`TestCallMicroflowUnknownResultTypeStillDeclaresVariable`.
Test and script hardening:
- `docker/check_test.go` and `docker/detect_test.go` set
`PATH=t.TempDir()` instead of `PATH=""` for the cache-preference
tests. Empty `PATH` confuses `exec.LookPath` on Linux (it falls
back to the current directory) and made the test flaky depending
on `os.Getwd()`. An empty temp directory is a clean "mx isn't on
PATH" signal.
- `scripts/run-mdl-tests.sh` now validates `$PROJECT_MPR`,
`$MXCLI_BIN`, `$TEST_SPEC`, `$BOOTSTRAP_MDL` with `[[ -f ... ]]`
guards. `${VAR:?...}` only fires on *unset* vars, so typo'd paths
previously produced an empty sandbox and confusing downstream
errors.1 parent 5227e8e commit edc4fa9
22 files changed
Lines changed: 573 additions & 12 deletions
File tree
- cmd/mxcli/docker
- mdl-examples/doctype-tests
- mdl/executor
- scripts
- sdk/mpr
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
125 | | - | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
126 | 128 | | |
127 | 129 | | |
128 | 130 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
272 | 272 | | |
273 | 273 | | |
274 | 274 | | |
275 | | - | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
276 | 278 | | |
277 | 279 | | |
278 | 280 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1301 | 1301 | | |
1302 | 1302 | | |
1303 | 1303 | | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
1304 | 1311 | | |
1305 | 1312 | | |
1306 | 1313 | | |
1307 | | - | |
| 1314 | + | |
1308 | 1315 | | |
1309 | 1316 | | |
1310 | 1317 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
509 | 509 | | |
510 | 510 | | |
511 | 511 | | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
82 | 85 | | |
83 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
84 | 96 | | |
85 | 97 | | |
86 | 98 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
57 | 57 | | |
58 | 58 | | |
59 | 59 | | |
| 60 | + | |
| 61 | + | |
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
| |||
68 | 70 | | |
69 | 71 | | |
70 | 72 | | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
83 | 100 | | |
84 | 101 | | |
85 | 102 | | |
| |||
94 | 111 | | |
95 | 112 | | |
96 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
97 | 119 | | |
98 | 120 | | |
99 | 121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
35 | 42 | | |
36 | 43 | | |
37 | 44 | | |
38 | 45 | | |
39 | | - | |
40 | 46 | | |
41 | 47 | | |
42 | 48 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
276 | 276 | | |
277 | 277 | | |
278 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
279 | 282 | | |
280 | 283 | | |
281 | 284 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
| 63 | + | |
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
| |||
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | | - | |
| 113 | + | |
114 | 114 | | |
115 | 115 | | |
116 | 116 | | |
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
134 | 140 | | |
135 | 141 | | |
136 | 142 | | |
| |||
140 | 146 | | |
141 | 147 | | |
142 | 148 | | |
143 | | - | |
| 149 | + | |
144 | 150 | | |
145 | 151 | | |
146 | 152 | | |
| |||
161 | 167 | | |
162 | 168 | | |
163 | 169 | | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
164 | 176 | | |
165 | 177 | | |
166 | 178 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
47 | 49 | | |
48 | 50 | | |
49 | 51 | | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
50 | 56 | | |
51 | 57 | | |
52 | 58 | | |
| |||
69 | 75 | | |
70 | 76 | | |
71 | 77 | | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
72 | 83 | | |
73 | 84 | | |
74 | 85 | | |
| |||
0 commit comments