-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: bson-5.0.0
-
Component/s: BSON
-
None
-
Fully Compatible
-
Ruby Drivers
I was testing out BSON Ruby master branch and found the following issue.
This commit introduces the breakage: 9484d2a0caa1414c4ec1e8cfb6cddf42e6e71cd4
The previous commit on master works fine: f7ffa3fc535cb6c1333abe0221278b852255432b
The error is:
- RangeError: bignum too big to convert into `long'
It happens on lib/bson/object_id.rb line 232
def generate_data
repair if defined?(@data)
@raw_data ||= @@generator.next_object_id
end
In a very minimal investigation I wasn't able make a script reproduce the issue, but the stack trace would indicate it has something to do with generating BSON object IDs when creating new Mongoid model objects-the line in question uses FactoryBot to create multiple objects in the same call. It fails reliably on the same tests 100%, so let me know if you aren't able to reproduce it I can probably pin it down.
Here is my stack trace:
RangeError: bignum too big to convert into `long' 0) TcServer::Booking::CartController#create with :orders param base case Failure/Error: let!(:menu_item1) { create(:t_menu_item, :with_providers, shop: shop, is_group_order: false) } RangeError: bignum too big to convert into `long' # ./.gem/ruby/3.2.0/bundler/gems/bson-ruby-9484d2a0caa1/lib/bson/object_id.rb:232:in `next_object_id' # ./.gem/ruby/3.2.0/bundler/gems/bson-ruby-9484d2a0caa1/lib/bson/object_id.rb:232:in `generate_data' # ./.gem/ruby/3.2.0/bundler/gems/bson-ruby-9484d2a0caa1/lib/bson/object_id.rb:130:in `hash' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/has_many/enumerable.rb:64:in `<<' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/has_many/proxy.rb:315:in `block in append' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/has_many/proxy.rb:332:in `with_add_callbacks' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/has_many/proxy.rb:314:in `append' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/has_many/proxy.rb:35:in `<<' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/belongs_to/binding.rb:29:in `block in bind_one' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/bindable.rb:35:in `block in binding' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/threaded/lifecycle.rb:55:in `_binding' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/bindable.rb:34:in `binding' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/belongs_to/binding.rb:22:in `bind_one' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/belongs_to/proxy.rb:27:in `block in initialize' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/proxy.rb:55:in `init' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/referenced/belongs_to/proxy.rb:25:in `initialize' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/relatable.rb:256:in `new' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/relatable.rb:256:in `create_relation' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/accessors.rb:46:in `create_relation' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/accessors.rb:27:in `__build__' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/accessors.rb:323:in `block (3 levels) in define_setter!' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/accessors.rb:215:in `without_autobuild' # ./.gem/ruby/3.2.0/gems/mongoid-7.5.4/lib/mongoid/association/accessors.rb:314:in `block (2 levels) in define_setter!' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:16:in `public_send' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:16:in `block (2 levels) in object' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:15:in `each' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:15:in `block in object' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/attribute_assigner.rb:14:in `object' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/evaluation.rb:13:in `object' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/strategy/create.rb:9:in `result' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/factory.rb:43:in `run' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:29:in `block in run' # ./.gem/ruby/3.2.0/gems/activesupport-7.0.8.1/lib/active_support/notifications.rb:208:in `instrument' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/factory_runner.rb:28:in `run' # ./.gem/ruby/3.2.0/gems/factory_bot-6.2.1/lib/factory_bot/strategy_syntax_method_registrar.rb:28:in `block in define_singular_strategy_method' # ./engines/tc_server/spec/controllers/booking/cart_controller_spec.rb:246:in `block (4 levels) in <main>' # ./.gem/ruby/3.2.0/gems/buildkite-test_collector-2.3.1/lib/buildkite/test_collector/library_hooks/rspec.rb:22:in `block (2 levels) in <main>' # ./.gem/ruby/3.2.0/gems/webmock-3.18.1/lib/webmock/rspec.rb:37:in `block (2 levels) in <main>'
- is duplicated by
-
RUBY-3438 BSON 5.0 regression, ObjectID generation broken after year 2038 (signed int)
- Closed