Skip to content

Commit ef74b5a

Browse files
engalarclaude
andcommitted
fix: consistent int32 array markers and remove debug logging
- Revert array markers from int64 back to int32 (verified against Studio Pro BSON) - Remove 26-line debug log block in writer_widgets_custom.go - Fix 4 comments that said int64 but code correctly uses int32 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ca65c96 commit ef74b5a

10 files changed

Lines changed: 21 additions & 49 deletions

sdk/mpr/writer_imagecollection.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ func (w *Writer) DeleteImageCollection(id string) error {
3232
}
3333

3434
func serializeImageCollection(ic *ImageCollection) ([]byte, error) {
35-
// Images array always starts with the array marker int64(3)
35+
// Images array always starts with the array marker int32(3)
3636
images := bson.A{int32(3)}
3737
for i := range ic.Images {
3838
img := &ic.Images[i]

sdk/mpr/writer_microflow.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func serializeSequenceFlow(flow *microflows.SequenceFlow) bson.D {
155155
switch cv := flow.CaseValue.(type) {
156156
case microflows.EnumerationCase:
157157
caseValues = bson.A{
158-
int64(2),
158+
int32(2),
159159
bson.D{
160160
{Key: "$ID", Value: idToBsonBinary(string(cv.ID))},
161161
{Key: "$Type", Value: "Microflows$EnumerationCase"},
@@ -164,7 +164,7 @@ func serializeSequenceFlow(flow *microflows.SequenceFlow) bson.D {
164164
}
165165
case *microflows.EnumerationCase:
166166
caseValues = bson.A{
167-
int64(2),
167+
int32(2),
168168
bson.D{
169169
{Key: "$ID", Value: idToBsonBinary(string(cv.ID))},
170170
{Key: "$Type", Value: "Microflows$EnumerationCase"},
@@ -611,7 +611,7 @@ func serializeTextTemplate(text *model.Text, params []string) bson.D {
611611
}
612612
if len(text.Translations) > 0 {
613613
var transArray bson.A
614-
transArray = append(transArray, int64(3)) // items marker (3 = has items)
614+
transArray = append(transArray, int32(3)) // items marker (3 = has items)
615615
for lang, value := range text.Translations {
616616
transArray = append(transArray, bson.D{
617617
{Key: "$ID", Value: idToBsonBinary(generateUUID())},

sdk/mpr/writer_microflow_actions.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func serializeMicroflowAction(action microflows.MicroflowAction) bson.D {
180180
// Serialize parameter mappings
181181
if len(a.ParameterMappings) > 0 {
182182
var mappings bson.A
183-
mappings = append(mappings, int64(3)) // Array marker (storageListType 3)
183+
mappings = append(mappings, int32(3)) // Array marker (storageListType 3)
184184
for _, pm := range a.ParameterMappings {
185185
mapping := bson.D{
186186
{Key: "$ID", Value: idToBsonBinary(string(pm.ID))},
@@ -216,7 +216,7 @@ func serializeMicroflowAction(action microflows.MicroflowAction) bson.D {
216216
// Serialize parameter mappings within MicroflowCall
217217
if len(a.MicroflowCall.ParameterMappings) > 0 {
218218
var mappings bson.A
219-
mappings = append(mappings, int64(2)) // Array marker
219+
mappings = append(mappings, int32(2)) // Array marker
220220
for _, pm := range a.MicroflowCall.ParameterMappings {
221221
mapping := bson.D{
222222
{Key: "$ID", Value: idToBsonBinary(string(pm.ID))},
@@ -247,7 +247,7 @@ func serializeMicroflowAction(action microflows.MicroflowAction) bson.D {
247247
// Serialize parameter mappings
248248
if len(a.ParameterMappings) > 0 {
249249
var mappings bson.A
250-
mappings = append(mappings, int64(2)) // Array marker
250+
mappings = append(mappings, int32(2)) // Array marker
251251
for _, pm := range a.ParameterMappings {
252252
mapping := bson.D{
253253
{Key: "$ID", Value: idToBsonBinary(string(pm.ID))},
@@ -461,7 +461,7 @@ func serializeRestCallAction(a *microflows.RestCallAction) bson.D {
461461
// Add parameters if present - each must be wrapped in TemplateParameter object
462462
if len(a.HttpConfiguration.LocationParams) > 0 {
463463
var params bson.A
464-
params = append(params, int64(2)) // Array marker
464+
params = append(params, int32(2)) // Array marker
465465
for _, p := range a.HttpConfiguration.LocationParams {
466466
templateParam := bson.D{
467467
{Key: "$ID", Value: idToBsonBinary(GenerateID())},
@@ -483,7 +483,7 @@ func serializeRestCallAction(a *microflows.RestCallAction) bson.D {
483483
// Serialize HttpHeaderEntries
484484
if len(a.HttpConfiguration.CustomHeaders) > 0 {
485485
var headers bson.A
486-
headers = append(headers, int64(2)) // Array marker
486+
headers = append(headers, int32(2)) // Array marker
487487
for _, h := range a.HttpConfiguration.CustomHeaders {
488488
header := bson.D{
489489
{Key: "$ID", Value: idToBsonBinary(string(h.ID))},
@@ -608,7 +608,7 @@ func serializeRestRequestHandling(rh microflows.RequestHandling) bson.D {
608608
// Add parameters - each must be wrapped in TemplateParameter object
609609
if len(h.TemplateParams) > 0 {
610610
var params bson.A
611-
params = append(params, int64(2)) // Array marker
611+
params = append(params, int32(2)) // Array marker
612612
for _, p := range h.TemplateParams {
613613
templateParam := bson.D{
614614
{Key: "$ID", Value: idToBsonBinary(GenerateID())},

sdk/mpr/writer_navigation.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func buildCaptionBson(text string) bson.D {
285285
{Key: "$ID", Value: idToBsonBinary(generateUUID())},
286286
{Key: "$Type", Value: "Texts$Text"},
287287
{Key: "Items", Value: bson.A{
288-
int64(1),
288+
int32(1),
289289
bson.D{
290290
{Key: "$ID", Value: idToBsonBinary(generateUUID())},
291291
{Key: "$Type", Value: "Texts$Translation"},

sdk/mpr/writer_odata.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ func (w *Writer) serializeConsumedODataService(svc *model.ConsumedODataService)
6464
"ExportLevel": "Hidden",
6565
"Metadata": svc.Metadata,
6666
"MetadataHash": svc.MetadataHash,
67-
"MetadataReferences": bson.A{int64(0)}, // empty BSON array marker
68-
"ValidatedEntities": bson.A{int64(0)}, // empty BSON array marker
67+
"MetadataReferences": bson.A{int32(0)}, // empty BSON array marker
68+
"ValidatedEntities": bson.A{int32(0)}, // empty BSON array marker
6969
"LastUpdated": "",
7070
"UseQuerySegment": false,
7171
"MinimumMxVersion": "",
@@ -203,7 +203,7 @@ func (w *Writer) DeletePublishedODataService(id model.ID) error {
203203

204204
// serializePublishedODataService converts a PublishedODataService to BSON bytes.
205205
func (w *Writer) serializePublishedODataService(svc *model.PublishedODataService) ([]byte, error) {
206-
// Authentication types array (versioned: starts with int64(3))
206+
// Authentication types array (versioned: starts with int32(3))
207207
authTypes := bson.A{int32(3)}
208208
for _, at := range svc.AuthenticationTypes {
209209
authTypes = append(authTypes, at)

sdk/mpr/writer_security.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func getBsonArray(doc bson.D, key string) bson.A {
8787
return nil
8888
}
8989

90-
// makeMendixArray builds a Mendix-style array: int64(1) marker followed by items.
90+
// makeMendixArray builds a Mendix-style array: int32(1) marker followed by items.
9191
func makeMendixArray(items ...any) bson.A {
9292
arr := bson.A{int32(1)}
9393
arr = append(arr, items...)

sdk/mpr/writer_widgets.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ func serializeWidgetArray(widgets []pages.Widget) bson.A {
2424
for _, w := range widgets {
2525
if w != nil {
2626
if !hasItems {
27-
arr = bson.A{int64(2)} // First item: change to version 2
27+
arr = bson.A{int32(2)} // First item: change to version 2
2828
hasItems = true
2929
}
3030
arr = append(arr, serializeWidget(w))
@@ -237,7 +237,7 @@ func SerializeCustomWidgetDataSource(ds pages.DataSource) bson.D {
237237
}
238238

239239
// Build SortItems array from Sorting field
240-
sortItems := bson.A{int64(2)} // Version marker for non-empty array
240+
sortItems := bson.A{int32(2)} // Version marker for non-empty array
241241
for _, sort := range d.Sorting {
242242
sortItem := bson.D{
243243
{Key: "$ID", Value: idToBsonBinary(generateUUID())},
@@ -526,7 +526,7 @@ func serializeClientTemplate(ct *pages.ClientTemplate, fallbackText *model.Text,
526526
// Build parameters array - use [3] for empty, [2, items...] for non-empty
527527
params := bson.A{int32(3)} // Empty array with version marker 3
528528
if ct != nil && len(ct.Parameters) > 0 {
529-
params = bson.A{int64(2)} // Non-empty array uses version marker 2
529+
params = bson.A{int32(2)} // Non-empty array uses version marker 2
530530
for _, param := range ct.Parameters {
531531
params = append(params, serializeClientTemplateParameter(param))
532532
}

sdk/mpr/writer_widgets_custom.go

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

55
import (
6-
"log"
7-
86
"github.com/mendixlabs/mxcli/sdk/pages"
97

108
"go.mongodb.org/mongo-driver/bson"
@@ -57,32 +55,6 @@ func serializeCustomWidgetWithRawType(cw *pages.CustomWidget) bson.D {
5755
var widgetObject any
5856
if cw.RawObject != nil {
5957
widgetObject = cw.RawObject
60-
// Debug: check for non-empty Widgets in RawObject at serialization time
61-
if cw.Name == "timelineCustom" {
62-
for _, elem := range cw.RawObject {
63-
if elem.Key == "Properties" {
64-
if arr, ok := elem.Value.(bson.A); ok {
65-
for _, item := range arr {
66-
if prop, ok := item.(bson.D); ok {
67-
for _, pe := range prop {
68-
if pe.Key == "Value" {
69-
if val, ok := pe.Value.(bson.D); ok {
70-
for _, ve := range val {
71-
if ve.Key == "Widgets" {
72-
if wa, ok := ve.Value.(bson.A); ok && len(wa) > 1 {
73-
log.Printf("SERIALIZE CHECK: timelineCustom Widgets: %d items (type: %T)", len(wa), wa[1])
74-
}
75-
}
76-
}
77-
}
78-
}
79-
}
80-
}
81-
}
82-
}
83-
}
84-
}
85-
}
8658
} else {
8759
// Build widget object (properties) - this still needs to match the raw type's PropertyType IDs
8860
// The ObjectTypeID is used to set the TypePointer on the WidgetObject

sdk/mpr/writer_widgets_layout.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func serializeLayoutGrid(lg *pages.LayoutGrid) bson.D {
6868
hasRows := false
6969
for _, row := range lg.Rows {
7070
if !hasRows {
71-
rows = bson.A{int64(2)} // First item: change to version 2
71+
rows = bson.A{int32(2)} // First item: change to version 2
7272
hasRows = true
7373
}
7474
rows = append(rows, serializeLayoutGridRow(row))
@@ -95,7 +95,7 @@ func serializeLayoutGridRow(row *pages.LayoutGridRow) bson.D {
9595
hasCols := false
9696
for _, col := range row.Columns {
9797
if !hasCols {
98-
cols = bson.A{int64(2)} // First item: change to version 2
98+
cols = bson.A{int32(2)} // First item: change to version 2
9999
hasCols = true
100100
}
101101
cols = append(cols, serializeLayoutGridColumn(col))

sdk/mpr/writer_workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ func serializeCallWorkflowActivity(a *workflows.CallWorkflowActivity) bson.D {
505505
bson.E{Key: "Name", Value: a.Name},
506506
)
507507

508-
// ParameterMappings (always present, marker int64(2))
508+
// ParameterMappings (always present, marker int32(2))
509509
paramMappings := bson.A{int32(2)}
510510
for _, pm := range a.ParameterMappings {
511511
pmID := string(pm.ID)

0 commit comments

Comments
 (0)