Skip to content

fix #583: parse StringAttributeType.Length across BSON numeric widths#584

Merged
ako merged 1 commit into
mainfrom
fix/583-string-attribute-length
May 22, 2026
Merged

fix #583: parse StringAttributeType.Length across BSON numeric widths#584
ako merged 1 commit into
mainfrom
fix/583-string-attribute-length

Conversation

@ako
Copy link
Copy Markdown
Collaborator

@ako ako commented May 22, 2026

Summary

  • Fixes describe entity and CATALOG.ATTRIBUTES misreport String attribute lengths #583. parseAttributeType in sdk/mpr/parser_domainmodel.go asserted raw["Length"].(int32), but Mendix Studio Pro stores the Length field as BSON int64. The assertion failed silently and Length defaulted to 0, so every String attribute surfaced as String(unlimited) in describe entity and Length: 0 in CATALOG.ATTRIBUTES.
  • Swapped the narrow assertion for the existing extractInt(raw["Length"]) helper (sdk/mpr/parser.go:44), which handles int32/int64/int/float64. Both surfaces share the same parsed value, so one fix repairs both.
  • Added sdk/mpr/parser_domainmodel_test.go covering all four numeric widths plus the missing-field case. The test fails on main (3 of 5 subtests) and passes after the patch.
  • Added mdl-examples/bug-tests/583-string-attribute-length-roundtrip.mdl for end-to-end regression (verified locally on a Mendix 11.9 project — finite lengths and unlimited both render correctly).
  • Updated the symptom-table row in .claude/skills/fix-issue.md so the next narrow-int-assertion bug is a one-table lookup.

Verification

Before, on a real project:

$ mxcli -p Evora-FactoryManagement.mpr -c "describe entity AgentCommons.Agent"
  Title: String(unlimited),
  Description: String(unlimited),
  UUID: String(unlimited),
  ...

After:

  Title: String(50),
  Description: String(200),
  UUID: String(200),
  ...

Catalog query goes from Length: 0 for every row to the real values (50, 200, …).

Note on scope

Other parsers use the same narrow int32 assertion 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 on main before patch
  • make build && make test — pass
  • Manual: mxcli describe entity AgentCommons.Agent on Evora-FactoryManagement (Mendix 11.9) — finite lengths now show correctly
  • Manual: SELECT Name, DataType, Length FROM CATALOG.ATTRIBUTES — same project, Length column now matches Studio Pro

🤖 Generated with Claude Code

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>
@github-actions
Copy link
Copy Markdown

AI Code Review

Critical Issues

None found.

Moderate Issues

None found.

Minor Issues

None found.

What Looks Good

  • Bug fix correctness: The PR correctly identifies and fixes the root cause (BSON int64 vs int32 assertion mismatch) by replacing the narrow type assertion with the robust extractInt helper. This resolves both describe entity output and CATALOG.ATTRIBUTES.Length values.
  • Test coverage:
    • Unit test (sdk/mpr/parser_domainmodel_test.go) covers all numeric widths (int32, int64, int, float64) and missing field case.
    • End-to-end MDL test (mdl-examples/bug-tests/583-string-attribute-length-roundtrip.mdl) validates roundtrip behavior in a real project context.
    • Tests fail on main and pass after patch, confirming the fix.
  • Verification: Manual validation on Mendix 11.9 project shows correct lengths in both describe entity and catalog queries.
  • Documentation: Symptom table updated in .claude/skills/fix-issue.md for future reference.
  • Scope adherence: PR stays focused on StringAttributeType.Length (out-of-scope parsers noted for follow-up).
  • Code quality: Uses existing helper (extractInt), maintains consistency with other BSON parsing patterns, no duplication.

Recommendation

Approve 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

@ako ako merged commit 0efb463 into main May 22, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

describe entity and CATALOG.ATTRIBUTES misreport String attribute lengths

1 participant