-
Type:
Bug
-
Resolution: Unresolved
-
Priority:
Minor - P4
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
Ruby Drivers
-
None
-
None
-
None
-
None
-
None
-
None
Failure
spec/bson/byte_buffer_write_spec.rb:508 ("BSON::ByteBuffer#put_double when argument is a string raises TypeError") fails on Ruby head:
expected TypeError with message matching /no implicit conversion to float from string|ClassCastException:.*RubyString cannot be cast to.*RubyFloat/, got #<TypeError: no implicit conversion of String into Float>
Cause
Ruby head changed the wording of the standard TypeError message produced when coercing a String to a Float:
- Ruby ≤ 3.4: no implicit conversion to float from string
- Ruby head: no implicit conversion of String into Float
The current regex on line 511 only matches the old MRI wording (or the JRuby ClassCastException form). The C extension's put_double propagates the standard Ruby TypeError verbatim, so when Ruby's wording changes the spec breaks.
Fix
Extend the regex on spec/bson/byte_buffer_write_spec.rb:511 to accept both wordings, e.g.:
/no implicit conversion to float from string|no implicit conversion of String into Float|ClassCastException:.*RubyString cannot be cast to.*RubyFloat/i
No production code changes; this is purely a test-message-tolerance fix.
Notes
Surfaced while running CI on the RUBY-3860 branch; not related to that ticket. Filed separately to keep the security PR focused.