Skip to content

Commit 4b63cb5

Browse files
authored
Merge pull request #1995 from ako/claude/wonderful-hypatia-x7mmyq
fix(git-merge): report a failed mx diff side instead of dropping the report (#1981)
2 parents 819a29a + 92309d9 commit 4b63cb5

4 files changed

Lines changed: 61 additions & 6 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"area": "cmd/mxcli", "date": "2026-11-06", "symptom": "`mxcli git merge` on ManualResolutionRequired printed no property-level report at all when either side's mx diff failed (exit 129 on a constant whose ExportLevel was \"\" on one side and Hidden on the other), so a reader could not tell 'no details' from 'the diff crashed'", "cause": "The call site only called propertyReport when both diffs returned nil, with no else; propertyReport already rendered a missing file as '(diff unavailable: …)', but never saw the run's error", "file": "cmd/mxcli/cmd_git_merge.go (exit-2 branch, propertyReport)", "fix": "propertyReport takes each side's diff error (diffSide) and is always called: a failed side prints '(diff unavailable: <error on one line>)', the other side its changes", "insight": "A guard that skips output on any error turns one side's failure into silence about both; let the renderer own each side's failure. The mx diff crash itself reproduces on 11.14.0 (\"\" vs Hidden ExportLevel: exit 129), see ako/mxcli#1980", "refs": "ako/mxcli#1981, mendixlabs/mxcli#1750", "test": "cmd/mxcli/gitmerge_test.go (TestGitMerge_FailedDiffIsReportedNotSkipped)"}

‎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
- **`create constant` writes `ExportLevel: Hidden`, as Studio Pro does** (ako/mxcli#1980, mendixlabs/mxcli#1749) — it wrote `""`, which `mx check` accepts but `mx diff` crashes on against a `Hidden` copy (exit 129), taking `git merge`'s report with it. `create or modify constant` now keeps a stored level instead of clearing it, and repairs a stored `""`.
19+
- **`git merge` reports the side whose `mx diff` failed instead of dropping the report** (ako/mxcli#1981, mendixlabs/mxcli#1750) — when one side's diff failed, no property-level report was printed at all. The side that worked is shown, and the failing side reads `(diff unavailable: <why>)`.
1920
- **`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.
2021
- **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.
2122
- **`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.

‎cmd/mxcli/cmd_git_merge.go‎

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,9 @@ func mergeRun(mprPath, ref, message, strategy, plan string, push bool, runners m
313313
theirsJSON := filepath.Join(tmp, "theirs-diff.json")
314314
d1 := runners.diff(filepath.Join(baseDir, filepath.FromSlash(repo.MPRPath)), oursMpr, oursJSON)
315315
d2 := runners.diff(filepath.Join(baseDir, filepath.FromSlash(repo.MPRPath)), filepath.Join(theirsDir, filepath.FromSlash(repo.MPRPath)), theirsJSON)
316-
if d1 == nil && d2 == nil {
317-
fmt.Fprintln(out, propertyReport(oursJSON, theirsJSON, manual))
318-
}
316+
// A failed side is reported, not dropped: skipping the report made
317+
// "the diff crashed" read as "no details" (ako/mxcli#1981).
318+
fmt.Fprintln(out, propertyReport(diffSide{oursJSON, d1}, diffSide{theirsJSON, d2}, manual))
319319
}
320320
if err := writePlanTemplate(mprPath, baseSha, oursSha, theirsSha, manual); err != nil {
321321
fmt.Fprintf(out, " (could not write the plan template: %v)\n", err)
@@ -720,15 +720,30 @@ type mxDiffFile struct {
720720
UnitDifferences []mxDiffUnit `json:"unitDifferences"`
721721
}
722722

723+
// diffSide is one side's mx diff: the file it was asked to write, and the
724+
// error the run returned, if it failed.
725+
type diffSide struct {
726+
path string
727+
err error
728+
}
729+
723730
// propertyReport renders the two mx diff files as one property-level report
724-
// over the conflicted units: what each side changed.
725-
func propertyReport(oursJSON, theirsJSON string, unitIDs []string) string {
731+
// over the conflicted units: what each side changed. A side whose diff failed
732+
// says why, on one line, and the other side is reported as usual.
733+
func propertyReport(ours, theirs diffSide, unitIDs []string) string {
726734
want := map[string]bool{}
727735
for _, id := range unitIDs {
728736
want[id] = true
729737
}
730738
lines := map[string][]string{}
731-
for _, f := range []struct{ side, path string }{{"Yours", oursJSON}, {"Theirs", theirsJSON}} {
739+
for _, f := range []struct {
740+
side string
741+
diffSide
742+
}{{"Yours", ours}, {"Theirs", theirs}} {
743+
if f.err != nil {
744+
lines[f.side] = append(lines[f.side], fmt.Sprintf(" (diff unavailable: %s)", strings.Join(strings.Fields(f.err.Error()), " ")))
745+
continue
746+
}
732747
raw, err := os.ReadFile(f.path)
733748
if err != nil {
734749
lines[f.side] = append(lines[f.side], fmt.Sprintf(" (diff unavailable: %v)", err))

‎cmd/mxcli/gitmerge_test.go‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,3 +1002,41 @@ func TestGitMerge_PlanTemplateFollowsEngineConflictList(t *testing.T) {
10021002
}
10031003
gitInE(t, dir, "merge", "--abort")
10041004
}
1005+
1006+
// ako/mxcli#1981 (mendixlabs/mxcli#1750): when one side's mx diff failed, the
1007+
// whole property report was skipped without a word, so a reader could not tell
1008+
// "no details" from "the diff crashed". The side that worked is reported, and
1009+
// the failing side says why.
1010+
func TestGitMerge_FailedDiffIsReportedNotSkipped(t *testing.T) {
1011+
dir, mprPath := modelConflictRepo(t)
1012+
doctorEnv(t, dir)
1013+
fixture := `{"unitDifferences":[{"id":"` + tDM + `","type":"DomainModels$DomainModel","change":"Modified","changeDetails":[{"change":"Modified","changeDescription":"Attribute 'MyFirstModule.CreatedByMxcli.Nickname'","changeDetails":[{"property":"New type > Length","baseValue":"100","mineValue":"150"}]}]}]}`
1014+
calls := 0
1015+
mx := mxRunners{
1016+
merge: func(base, mine, theirs string, shas [3]string) (int, string, error) {
1017+
return 2, `[{"ConflictResolutionDetails":"ManualResolutionRequired"}]`, nil
1018+
},
1019+
diff: func(base, mine, outJSON string) error {
1020+
calls++
1021+
if calls == 2 { // theirs
1022+
return errors.New("mx diff: exit status 129: Comparing apps\nException during diffing:\nValue cannot be null. (Parameter 'element')")
1023+
}
1024+
return os.WriteFile(outJSON, []byte(fixture), 0o644)
1025+
},
1026+
}
1027+
var out bytes.Buffer
1028+
if err := mergeRun(mprPath, "side", "", "", "", false, mx, &out); err == nil {
1029+
t.Fatal("a manual conflict must end with the decision error")
1030+
}
1031+
report := out.String()
1032+
for _, want := range []string{
1033+
"Property-level changes",
1034+
"150",
1035+
"(diff unavailable: mx diff: exit status 129: Comparing apps Exception during diffing: Value cannot be null. (Parameter 'element'))",
1036+
} {
1037+
if !strings.Contains(report, want) {
1038+
t.Errorf("report must contain %q:\n%s", want, report)
1039+
}
1040+
}
1041+
gitInE(t, dir, "merge", "--abort") // clean up the fixture
1042+
}

0 commit comments

Comments
 (0)