Skip to content

fix(docker): preserve MPRv2 storage format across docker check#764

Open
dimenus wants to merge 1 commit into
mendixlabs:mainfrom
dimenus:fix/763-preserve-mprv2-storage-format
Open

fix(docker): preserve MPRv2 storage format across docker check#764
dimenus wants to merge 1 commit into
mendixlabs:mainfrom
dimenus:fix/763-preserve-mprv2-storage-format

Conversation

@dimenus

@dimenus dimenus commented Jul 17, 2026

Copy link
Copy Markdown

Closes #763

What does it do?

mxcli docker check runs mx update-widgets before mx check to prevent false CE0463 ("widget definition changed") errors. On an MPRv2 project, that step rewrites the project into the self-contained MPRv1 format: it inlines every unit into the .mpr and deletes the mprcontents/ directory. A command named check should not change the on-disk storage format.

On a project under Git this is damaging. After the conversion the working tree no longer matches the mprcontents/*.mxunit files tracked in the repository. If the project is then opened in Studio Pro (which auto-converts back to MPRv2) or the state is committed, the history and the on-disk format drift apart. In the case that motivated this, Studio Pro then failed to open the project, crashing in its Git version-control provider.

The fix detects the storage format before running update-widgets. When the project is MPRv2, it snapshots the .mpr and mprcontents/ to a temp directory and restores them after the check. The check still runs against the widget-normalized model, so CE0463 false positives stay suppressed; only the on-disk format is preserved. MPRv1 projects are single-file and left untouched. If the snapshot cannot be taken, update-widgets is skipped rather than risk an unrecoverable conversion.

Testing

  • go build ./cmd/mxcli/... — passes
  • go vet ./cmd/mxcli/docker/... — passes
  • go test ./cmd/mxcli/docker/... — unit tests pass, including the new TestSnapshotStorageFormat_RestoresV2AfterConversion. Mutation-checked: the test fails when the restore is disabled.
  • Integration test TestCheck_PreservesMPRv2StorageFormat (build tag integration): scaffolds a real MPRv2 project with mx create-project, runs the real Check(), and asserts the project is still MPRv2. Verified green in a Linux container with the same mx version the CI integration job installs (11.9.0). Mutation-checked: it fails (project ends MPRv1) when the fix is disabled.
  • Root cause confirmed on both mx 11.9.0 and 11.12.1: mx update-widgets performs the v2 to v1 conversion.

Mendix validation

Verified against a real MPRv2 project (Mendix 11.12.1): before the fix, mxcli docker check left the project MPRv1 with mprcontents/ deleted; after the fix, the project stays byte-for-byte MPRv2 and git reports no model changes.

Agentic Code Testing

N/A — this changes the behavior of docker check, not an MDL command surface.

🤖 Generated with Claude Code

`mxcli docker check` runs `mx update-widgets` before `mx check` to avoid false
CE0463 ("widget definition changed") errors. On an MPRv2 project that step
rewrites the project into the self-contained MPRv1 format: it inlines every unit
into the .mpr and deletes the mprcontents/ directory. A command named `check`
should not change the on-disk storage format. On a project under Git this
desyncs the working tree from the tracked mprcontents/ files and can leave
Studio Pro unable to open the project (it crashed in its Git version-control
provider in the case that motivated this).

## Changes

- Detect the storage format before running update-widgets. When the project is
  MPRv2, snapshot the .mpr and mprcontents/ to a temp directory and restore them
  after the check. The check still runs against the widget-normalized model, so
  CE0463 false positives stay suppressed; only the on-disk format is preserved.
  MPRv1 projects are single-file and left untouched.
- If the snapshot cannot be taken, skip update-widgets rather than risk an
  unrecoverable v2 to v1 conversion.

## Tests

- Unit regression test for the snapshot/restore round-trip (deletes mprcontents/
  to mimic the conversion, asserts a byte-for-byte restore).
- Integration test (build tag `integration`) that scaffolds a real MPRv2 project
  with `mx create-project`, runs the real `Check()`, and asserts the project is
  still MPRv2 afterwards.

## Benefits

- `docker check` no longer mutates the storage format of the project it checks.
- Removes the Git working-tree desync and the Studio Pro open failure that
  followed from it.

## Statistics

- 3 files changed: 1 fix, 2 tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mxcli docker check silently converts MPRv2 projects to MPRv1 (via mx update-widgets), deleting mprcontents

2 participants