Skip to content

fix #585: parse remaining numeric BSON fields across all numeric widths#587

Merged
ako merged 1 commit into
mainfrom
fix/585-narrow-int32-assertions
May 22, 2026
Merged

fix #585: parse remaining numeric BSON fields across all numeric widths#587
ako merged 1 commit into
mainfrom
fix/585-narrow-int32-assertions

Conversation

@ako
Copy link
Copy Markdown
Collaborator

@ako ako commented May 22, 2026

Summary

Sweeps the same BSON-numeric-width bug class fixed in #583 (and PR #584) across the remaining parsers that still used raw["X"].(int32). Studio Pro writes these fields as BSON int64, so the assertions silently failed and the values defaulted to 0.

Fields fixed:

File Field Surface affected
sdk/mpr/parser_misc.go JsonElement.MinOccurs JSON-structure occurrence constraints
sdk/mpr/parser_misc.go JsonElement.MaxOccurs JSON-structure occurrence constraints
sdk/mpr/parser_misc.go JsonElement.MaxLength XSD maxLength facet in import/export mappings
sdk/mpr/parser_misc.go JsonElement.FractionDigits Decimal precision in JSON structures
sdk/mpr/parser_misc.go JsonElement.TotalDigits Decimal precision in JSON structures
sdk/mpr/parser_enumeration.go ScheduledEvent.Interval Scheduled-event cadence (real events appeared as interval 0)

Also collapsed the existing int32/int64 if-else chain in parseClosePageAction (NumberOfPagesToClose) to use the same extractInt helper — same intent, less repetition.

For each numeric field the Length-style defaulting is preserved with if _, ok := raw["X"]; ok { ... = extractInt(...) } so the sentinel defaults (MaxLength: -1, etc.) survive when the field is absent.

What is intentionally left alone

The five .(int32) probes in parser.go (array-marker handling) and parser_microflow_actions.go (parameter-mapping prefix skip) are type-discriminators, not value reads — Mendix BSON-array prefix markers really are stored as int32. The PR description in #585 already called these out.

Tests

  • sdk/mpr/parser_misc_test.go — five JsonElement facets × four numeric widths × missing → 25 sub-cases. Fails on main for every non-int32 width.
  • sdk/mpr/parser_scheduledevent_test.goInterval across int32/int64/int/float64/missing. Fails on main for int64 and float64.

Mirrors the parametrised template introduced in PR #584.

Skill update

The narrow-int32 row in .claude/skills/fix-issue.md is rewritten to cover the broader symptom (any numeric BSON field misreported as 0/unlimited), names every affected field, and adds a sweep command. References both #583 and #585.

Test plan

  • go test ./sdk/mpr/... — passes (including new tests); new tests fail on main before the patch
  • make build && make test && make lint — all pass
  • Verified the new parametrised tests collectively show 4 PASS / 21 FAIL on main before applying the fix

🤖 Generated with Claude Code

Six more numeric facets read with the same narrow `.(int32)` assertion
fixed in #583 for StringAttributeType.Length. Studio Pro writes them as
BSON int64; mxcli was silently returning 0 for all of them:

- JsonElement.MinOccurs / MaxOccurs / MaxLength / FractionDigits /
  TotalDigits (parser_misc.go) — XSD facets in JSON Structures
- ScheduledEvent.Interval (parser_enumeration.go) — scheduled-event
  cadence; misreport showed real events as "interval 0"

Also collapsed parseClosePageAction's int32/int64 if-else chain
(NumberOfPagesToClose) to the same extractInt helper for consistency.

The five existing array-marker probes in parser.go and
parser_microflow_actions.go are left as-is; those probe for `int32`
intentionally because Mendix BSON-array prefix markers really are
stored as int32 type discriminators, not as values to read.

Added two test files mirroring the #583 template:
- parser_misc_test.go — five JsonElement facets × four numeric widths
- parser_scheduledevent_test.go — Interval across numeric widths

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

AI Code Review

What Looks Good

  • Bug fix consistency: The PR correctly identifies and fixes the same BSON numeric width bug class previously addressed in describe entity and CATALOG.ATTRIBUTES misreport String attribute lengths #583/fix #583: parse StringAttributeType.Length across BSON numeric widths #584, replacing unsafe .(int32) assertions with the robust extractInt helper across all affected numeric fields (JsonElement facets, ScheduledEvent.Interval, ClosePageAction.NumberOfPagesToClose).
  • Test coverage: Added comprehensive parametrized tests (parser_misc_test.go, parser_scheduledevent_test.go) that validate correct parsing across all BSON numeric widths (int32, int64, int, float64) and missing field handling, mirroring the approach from fix #583: parse StringAttributeType.Length across BSON numeric widths #584. Tests confirm the fix resolves silent failures where values defaulted to 0/unlimited.
  • Default preservation: Maintains existing sentinel defaults (e.g., MaxLength: -1) for absent fields via if _, ok := raw["X"]; ok { ... } guards, preserving backward compatibility.
  • Code deduplication: Collapsed redundant int32/int64 if-else chain in parseClosePageAction to use extractInt, reducing repetition while maintaining the same logic.
  • Skill update: Updated .claude/skills/fix-issue.md to reflect the broader symptom pattern, document all affected fields, and add a sweep command (grep -n '\.(int32)' sdk/mpr/parser_*.go), improving future issue diagnosis.
  • Selective application: Correctly left alone intentional .(int32) uses in parser.go and parser_microflow_actions.go that serve as BSON array-type discriminators (not value reads), as noted in the PR description.

Recommendation

Approve – The PR thoroughly addresses the BSON numeric width bug class with minimal, focused changes, comprehensive test coverage, and proper preservation of existing behavior. No checklist violations are present.


Automated review via OpenRouter (Nemotron Super 120B) — workflow source

@ako ako merged commit 4f0293f 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.

1 participant