Skip to content

Tolerate any BSON numeric representation when deserializing concepts#2302

Merged
einari merged 1 commit into
mainfrom
fix/concept-serializer-numeric-coercion
Jun 17, 2026
Merged

Tolerate any BSON numeric representation when deserializing concepts#2302
einari merged 1 commit into
mainfrom
fix/concept-serializer-numeric-coercion

Conversation

@einari

@einari einari commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

Fixed

  • ConceptAs<T> values now deserialize from MongoDB regardless of the stored BSON numeric type. Numeric concepts (for example an int-backed concept) read with a representation-specific reader previously threw ReadInt32 can only be called when CurrentBsonType is Int32, not when CurrentBsonType is Double when the stored value had a different numeric representation — which happens when integral values flow through JSON-based pipelines (such as Chronicle projections that materialize event content via ExpandoObject) and are persisted as Double. The value is now read according to its actual stored BSON type and converted to the concept's underlying type.

ConceptSerializer read a numeric concept with a representation-specific
reader (for example ReadInt32 for an int concept), which threw when the
stored BSON type differed - notably when integral values flow through
JSON-based pipelines (Chronicle projections materializing event content
via ExpandoObject) and are persisted as Double. Read according to the
actual stored BSON type and convert to the concept's underlying type so
a concept deserializes regardless of how its value was stored.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@einari einari added the patch label Jun 17, 2026
@github-actions

Copy link
Copy Markdown

NuGet packages for this PR, e.g. Cratis.Arc:
https://github.com/cratis/arc/packages/1655206?version=20.43.3

@einari einari merged commit 1da7d3c into main Jun 17, 2026
50 checks passed
@einari einari deleted the fix/concept-serializer-numeric-coercion branch June 17, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant