{"record":{"id":"0fca699139d72670","repo":"mongodb/mongoid","slug":"an-around-callback-must-contain-a-yield-in-its-def","errorCode":null,"errorMessage":"An around callback must contain a yield in its definition.","messagePattern":"An around callback must contain a yield in its definition\\.","errorType":"exception","errorClass":"Mongoid::Errors::InvalidAroundCallback","httpStatus":null,"severity":"error","filePath":"lib/mongoid/interceptable.rb","lineNumber":185,"sourceCode":"    #\n    #  @api private\n    def _mongoid_run_child_callbacks_with_around(kind, children: nil, &block)\n      children ||= cascadable_children(kind)\n      with_children = !Mongoid::Config.prevent_multiple_calls_of_embedded_callbacks\n\n      return block&.call if children.empty?\n\n      fibers = children.map do |child|\n        Fiber.new do\n          child.run_callbacks(child_callback_type(kind, child), with_children: with_children) do\n            Fiber.yield\n          end\n        end\n      end\n\n      fibers.each do |fiber|\n        fiber.resume\n        raise Mongoid::Errors::InvalidAroundCallback unless fiber.alive?\n      end\n\n      block&.call\n\n      fibers.reverse.each(&:resume)\n    end\n\n    # Execute the callbacks of given kind for embedded documents without\n    # around callbacks.\n    #\n    # @param [ Symbol ] kind The type of callback to execute.\n    # @param [ Array<Document> ] children Children to execute callbacks on. If\n    #   nil, callbacks will be executed on all cascadable children of\n    #   the document.\n    #\n    # @api private\n    def _mongoid_run_child_callbacks_without_around(kind, children: nil, &block)\n      children ||= cascadable_children(kind)","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/interceptable.rb#L167-L203","documentation":"Raised by _mongoid_run_child_callbacks_with_around when an embedded child's around callback completes without yielding, which would otherwise silently skip the rest of the callback chain and the wrapped operation. The check runs after resuming each child's fiber.","triggerScenarios":"Thrown at lib/mongoid/interceptable.rb:185 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure every around callback body contains a yield statement","Review custom around_* callbacks defined on embedded models and add the missing yield"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","contentChangedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}