Skip to content

Commit 295c757

Browse files
engalarengalarclaude
authored
fix: int32→int64 for BSON property values, consistent array markers (#71)
Property values must be int64 in BSON — Studio Pro's type cache matches by BSON type and crashes with "Sequence contains no matching element" on int32. Array markers remain int32 (verified against Studio Pro BSON). - Convert all property values from int32 to int64 across writer_*.go - Add safeInt64() helper for settings serialization - Remove debug logging left in writer_widgets_custom.go - Fix 4 comments that incorrectly referenced int64 for array markers - Add golden .mxunit files from Studio Pro for roundtrip testing Co-authored-by: engalar <wengao.liu@siemens.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent e464177 commit 295c757

18 files changed

+76
-83
lines changed
1.65 KB
Binary file not shown.
9.47 KB
Binary file not shown.
431 KB
Binary file not shown.
1.16 MB
Binary file not shown.

sdk/mpr/writer_dbconnection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func serializeDBQuery(q *model.DatabaseQuery) bson.M {
8888
"$Type": "DatabaseConnector$DatabaseQuery",
8989
"Name": q.Name,
9090
"Query": q.SQL,
91-
"QueryType": int32(q.QueryType),
91+
"QueryType": int64(q.QueryType),
9292
}
9393
if q.ID != "" {
9494
qDoc["$ID"] = idToBsonBinary(string(q.ID))

sdk/mpr/writer_microflow.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ func serializeSequenceFlow(flow *microflows.SequenceFlow) bson.D {
178178
{Key: "$ID", Value: idToBsonBinary(string(flow.ID))},
179179
{Key: "$Type", Value: "Microflows$SequenceFlow"},
180180
{Key: "CaseValues", Value: caseValues},
181-
{Key: "DestinationConnectionIndex", Value: int32(flow.DestinationConnectionIndex)},
181+
{Key: "DestinationConnectionIndex", Value: int64(flow.DestinationConnectionIndex)},
182182
{Key: "DestinationPointer", Value: idToBsonBinary(string(flow.DestinationID))},
183183
{Key: "IsErrorHandler", Value: flow.IsErrorHandler},
184184
{Key: "Line", Value: bson.D{
@@ -187,7 +187,7 @@ func serializeSequenceFlow(flow *microflows.SequenceFlow) bson.D {
187187
{Key: "DestinationControlVector", Value: "0;0"},
188188
{Key: "OriginControlVector", Value: "0;0"},
189189
}},
190-
{Key: "OriginConnectionIndex", Value: int32(flow.OriginConnectionIndex)},
190+
{Key: "OriginConnectionIndex", Value: int64(flow.OriginConnectionIndex)},
191191
{Key: "OriginPointer", Value: idToBsonBinary(string(flow.OriginID))},
192192
}
193193
}
@@ -197,15 +197,15 @@ func serializeAnnotationFlow(af *microflows.AnnotationFlow) bson.D {
197197
return bson.D{
198198
{Key: "$ID", Value: idToBsonBinary(string(af.ID))},
199199
{Key: "$Type", Value: "Microflows$AnnotationFlow"},
200-
{Key: "DestinationConnectionIndex", Value: int32(0)},
200+
{Key: "DestinationConnectionIndex", Value: int64(0)},
201201
{Key: "DestinationPointer", Value: idToBsonBinary(string(af.DestinationID))},
202202
{Key: "Line", Value: bson.D{
203203
{Key: "$ID", Value: idToBsonBinary(generateUUID())},
204204
{Key: "$Type", Value: "Microflows$BezierCurve"},
205205
{Key: "DestinationControlVector", Value: "0;0"},
206206
{Key: "OriginControlVector", Value: "0;0"},
207207
}},
208-
{Key: "OriginConnectionIndex", Value: int32(0)},
208+
{Key: "OriginConnectionIndex", Value: int64(0)},
209209
{Key: "OriginPointer", Value: idToBsonBinary(string(af.OriginID))},
210210
}
211211
}
@@ -527,17 +527,17 @@ func serializeMicroflowObject(obj microflows.MicroflowObject) bson.D {
527527
func serializePoint(pt model.Point) bson.D {
528528
return bson.D{
529529
{Key: "$Type", Value: "Common$Point"},
530-
{Key: "X", Value: int32(pt.X)},
531-
{Key: "Y", Value: int32(pt.Y)},
530+
{Key: "X", Value: int64(pt.X)},
531+
{Key: "Y", Value: int64(pt.Y)},
532532
}
533533
}
534534

535535
// serializeSize serializes a Size to BSON (nested object format).
536536
func serializeSize(sz model.Size) bson.D {
537537
return bson.D{
538538
{Key: "$Type", Value: "Common$Size"},
539-
{Key: "Width", Value: int32(sz.Width)},
540-
{Key: "Height", Value: int32(sz.Height)},
539+
{Key: "Width", Value: int64(sz.Width)},
540+
{Key: "Height", Value: int64(sz.Height)},
541541
}
542542
}
543543

sdk/mpr/writer_microflow_actions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ func serializeMicroflowAction(action microflows.MicroflowAction) bson.D {
373373
{Key: "$ID", Value: idToBsonBinary(string(a.ID))},
374374
{Key: "$Type", Value: "Microflows$CloseFormAction"},
375375
{Key: "ErrorHandlingType", Value: "Rollback"},
376-
{Key: "NumberOfPagesToClose", Value: int32(a.NumberOfPages)},
376+
{Key: "NumberOfPagesToClose", Value: int64(a.NumberOfPages)},
377377
}
378378
return doc
379379

sdk/mpr/writer_modules.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ func (w *Writer) serializeModule(module *model.Module) ([]byte, error) {
250250
"AppStoreVersionGuid": "",
251251
"IsThemeModule": false,
252252
"IsReusableComponent": module.IsReusableComponent,
253-
"NewSortIndex": int32(0),
253+
"NewSortIndex": int64(0),
254254
}
255255
return bson.Marshal(doc)
256256
}

sdk/mpr/writer_odata.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ func serializePublishedEntitySet(es *model.PublishedEntitySet, entityTypeID stri
284284
"$Type": "ODataPublish$EntitySet",
285285
"ExposedName": es.ExposedName,
286286
"UsePaging": es.UsePaging,
287-
"PageSize": int32(es.PageSize),
287+
"PageSize": int64(es.PageSize),
288288
}
289289

290290
// EntityTypePointer is a BY_ID reference

sdk/mpr/writer_pages.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ func (w *Writer) serializePage(page *pages.Page) ([]byte, error) {
128128
{Key: "Style", Value: ""},
129129
}},
130130
{Key: "Autofocus", Value: "DesktopOnly"},
131-
{Key: "CanvasHeight", Value: int32(600)},
132-
{Key: "CanvasWidth", Value: int32(1200)},
131+
{Key: "CanvasHeight", Value: int64(600)},
132+
{Key: "CanvasWidth", Value: int64(1200)},
133133
{Key: "Documentation", Value: page.Documentation},
134134
{Key: "Excluded", Value: page.Excluded},
135135
{Key: "ExportLevel", Value: "Hidden"},
@@ -209,9 +209,9 @@ func (w *Writer) serializePage(page *pages.Page) ([]byte, error) {
209209
doc = append(doc, bson.E{Key: "Parameters", Value: params})
210210

211211
doc = append(doc, bson.E{Key: "PopupCloseAction", Value: ""})
212-
doc = append(doc, bson.E{Key: "PopupHeight", Value: int32(600)})
212+
doc = append(doc, bson.E{Key: "PopupHeight", Value: int64(600)})
213213
doc = append(doc, bson.E{Key: "PopupResizable", Value: false})
214-
doc = append(doc, bson.E{Key: "PopupWidth", Value: int32(600)})
214+
doc = append(doc, bson.E{Key: "PopupWidth", Value: int64(600)})
215215

216216
// Add Title
217217
// Mendix uses [3] for empty arrays, [2, item1, item2, ...] for non-empty arrays
@@ -267,8 +267,8 @@ func (w *Writer) serializeSnippet(snippet *pages.Snippet) ([]byte, error) {
267267
doc := bson.D{
268268
{Key: "$ID", Value: idToBsonBinary(string(snippet.ID))},
269269
{Key: "$Type", Value: "Forms$Snippet"},
270-
{Key: "CanvasHeight", Value: int32(600)},
271-
{Key: "CanvasWidth", Value: int32(800)},
270+
{Key: "CanvasHeight", Value: int64(600)},
271+
{Key: "CanvasWidth", Value: int64(800)},
272272
{Key: "Documentation", Value: snippet.Documentation},
273273
{Key: "ExportLevel", Value: "Hidden"},
274274
{Key: "Name", Value: snippet.Name},

0 commit comments

Comments
 (0)