Skip to content

Fix RangeError by converting large integers to BSON::Decimal128#193

Merged
kenhys merged 1 commit intofluent:masterfrom
Watson1978:decimal
Feb 12, 2026
Merged

Fix RangeError by converting large integers to BSON::Decimal128#193
kenhys merged 1 commit intofluent:masterfrom
Watson1978:decimal

Conversation

@Watson1978
Copy link
Contributor

@Watson1978 Watson1978 commented Feb 12, 2026

MongoDB BSON only supports signed 64-bit integers (max 2^63 - 1).
When Fluentd processes integers exceeding this limit (e.g., uint64 from MessagePack), the MongoDB driver raises a RangeError.

This patch introduces a recursive check to detect integers larger than INT64_MAX and converts them to BSON::Decimal128.

Fix fluent/fluentd#4560, fluent/fluentd#4258

MongoDB BSON only supports signed 64-bit integers (max 2^63 - 1).
When Fluentd processes integers exceeding this limit (e.g., uint64 from MessagePack), the MongoDB driver raises a RangeError.

This patch introduces a recursive check to detect integers larger than INT64_MAX and converts them to BSON::Decimal128.

Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
Copy link
Contributor

@kenhys kenhys left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@kenhys kenhys merged commit 2e82160 into fluent:master Feb 12, 2026
25 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.

Flushing the buffer fails with BSON::Error::UnserializableClass error="Value does not define its BSON serialized type: 1721203518".

2 participants