fix #583: parse StringAttributeType.Length across BSON numeric widths#584
Merged
Conversation
Studio Pro stores the Length field on DomainModels$StringAttributeType as BSON int64, but parseAttributeType only accepted int32. The assertion failed silently, leaving Length at zero — every String attribute then surfaced as String(unlimited) in `describe entity` and Length: 0 in CATALOG.ATTRIBUTES, regardless of the actual max length set in the model. Switch to the existing extractInt helper, which already handles int32/int64/int/float64 the way other parser code paths do. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AI Code ReviewCritical IssuesNone found. Moderate IssuesNone found. Minor IssuesNone found. What Looks Good
RecommendationApprove the PR. The fix is correct, well-tested, and follows project conventions. No blocking issues identified. Automated review via OpenRouter (Nemotron Super 120B) — workflow source |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parseAttributeTypeinsdk/mpr/parser_domainmodel.goassertedraw["Length"].(int32), but Mendix Studio Pro stores theLengthfield as BSON int64. The assertion failed silently andLengthdefaulted to0, so every String attribute surfaced asString(unlimited)indescribe entityandLength: 0inCATALOG.ATTRIBUTES.extractInt(raw["Length"])helper (sdk/mpr/parser.go:44), which handlesint32/int64/int/float64. Both surfaces share the same parsed value, so one fix repairs both.sdk/mpr/parser_domainmodel_test.gocovering all four numeric widths plus the missing-field case. The test fails onmain(3 of 5 subtests) and passes after the patch.mdl-examples/bug-tests/583-string-attribute-length-roundtrip.mdlfor end-to-end regression (verified locally on a Mendix 11.9 project — finite lengths andunlimitedboth render correctly)..claude/skills/fix-issue.mdso the next narrow-int-assertion bug is a one-table lookup.Verification
Before, on a real project:
After:
Catalog query goes from
Length: 0for every row to the real values (50, 200, …).Note on scope
Other parsers use the same narrow
int32assertion on numeric fields —parser_misc.go(MaxLength/MinOccurs/MaxOccurs/FractionDigits/TotalDigits on JSON Structures),parser_enumeration.go(Interval), and a few others. They are out of scope for this PR (single concern) but are the same latent bug; happy to file a follow-up issue.Test plan
go test ./sdk/mpr/...— passes (including new test); fails onmainbefore patchmake build && make test— passmxcli describe entity AgentCommons.Agenton Evora-FactoryManagement (Mendix 11.9) — finite lengths now show correctlySELECT Name, DataType, Length FROM CATALOG.ATTRIBUTES— same project,Lengthcolumn now matches Studio Pro🤖 Generated with Claude Code