Skip to content

Other parsers share #583's narrow-int32 assertion: silently zeroes numeric fields when Studio Pro writes them as int64 #585

@ako

Description

@ako

Summary

PR #584 fixed the BSON-numeric-width bug for StringAttributeType.Length. The same narrow raw[\"X\"].(int32) pattern lives in several other parsers, each of which will silently report 0 for any value Mendix Studio Pro writes as BSON int64 (the same divergence that produced #583).

Affected fields

File:Line Field What surfaces silently as 0/unlimited
sdk/mpr/parser_misc.go:762 MinOccurs (JSON Structure element) JSON-structure occurrence constraints
sdk/mpr/parser_misc.go:765 MaxOccurs (JSON Structure element) JSON-structure occurrence constraints
sdk/mpr/parser_misc.go:774 MaxLength (JSON Structure element) XSD/JSON maxLength facet, used for import/export mapping validation
sdk/mpr/parser_misc.go:777 FractionDigits (JSON Structure element) Decimal precision in JSON structures
sdk/mpr/parser_misc.go:780 TotalDigits (JSON Structure element) Decimal precision in JSON structures
sdk/mpr/parser_enumeration.go:200 Interval (scheduled event) Scheduled-event interval value — would show as 0 → "never runs" in describe output

Also worth tidying (not buggy, but verbose):

Out of scope (don't touch):

  • parser.go:96/111/177 and parser_microflow_actions.go:249/270 — these intentionally probe for int32 because Mendix array-prefix markers really are stored as int32. The assertion is a type-discriminator, not a value read.

Proposed fix

For each row in the table, replace the narrow assertion with the existing extractInt(raw[\"X\"]) helper from sdk/mpr/parser.go:44, which accepts int32/int64/int/float64. Same pattern as #584.

Add unit tests in sdk/mpr/parser_misc_test.go and sdk/mpr/parser_enumeration_test.go (or parser_scheduledevent_test.go if the function is moved) parametrised on numeric width, mirroring TestParseAttributeType_StringLength_BsonNumericWidths from PR #584.

How this is likely to bite

Same pattern as #583: an AI agent (or a fixture script) reads MaxLength/MaxOccurs from mxcli describe import-mapping or mxcli describe json-structure, generates payloads under the assumption that no limit applies, and gets runtime rejections from Mendix's XSD validator. Scheduled-event misreport is more visible — describe output would show interval 0 for events that actually run on a real cadence.

Verification approach

For each affected field: hand-craft a BSON document (map[string]any{...}) with the field stored as int64, call the parser directly, assert the field is preserved. The Go unit test from #584 is a one-file template — copy-paste, swap the field name, and you have the failing test in one step.

Notes

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions