mongodb/mongoid · error · Mongoid::Errors::InvalidAroundCallback
An around callback must contain a yield in its definition.
Error message
An around callback must contain a yield in its definition.
What it means
Error "An around callback must contain a yield in its definition." thrown in mongodb/mongoid.
Source
Thrown at lib/mongoid/interceptable.rb:185
#
# @api private
def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block)
children ||= cascadable_children(kind)
with_children = !Mongoid::Config.prevent_multiple_calls_of_embedded_callbacks
return block&.call if children.empty?
fibers = children.map do |child|
Fiber.new do
child.run_callbacks(child_callback_type(kind, child), with_children: with_children) do
Fiber.yield
end
end
end
fibers.each do |fiber|
fiber.resume
raise Mongoid::Errors::InvalidAroundCallback unless fiber.alive?
end
block&.call
fibers.reverse.each(&:resume)
end
# Execute the callbacks of given kind for embedded documents without
# around callbacks.
#
# @param [ Symbol ] kind The type of callback to execute.
# @param [ Array<Document> ] children Children to execute callbacks on. If
# nil, callbacks will be executed on all cascadable children of
# the document.
#
# @api private
def _mongoid_run_child_callbacks_without_around(kind, children: nil, &block)
children ||= cascadable_children(kind)View on GitHub (pinned to 0da0e23d71)
When it happens
Trigger: Thrown at lib/mongoid/interceptable.rb:185 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mongodb/mongoid@0da0e23d71 (2026-08-23).
Data as JSON: /api/errors/0fca699139d72670.
Report an issue: GitHub.