{"record":{"id":"9a497d3ef06a0e10","repo":"mongodb/mongoid","slug":"on-conditions-for-after-commit-and-after-rollback","errorCode":null,"errorMessage":":on conditions for after_commit and after_rollback callbacks have to be one of #{CALLBACK_ACTIONS}","messagePattern":":on conditions for after_commit and after_rollback callbacks have to be one of #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/mongoid/clients/sessions.rb","lineNumber":226,"sourceCode":"          return unless options[:on]\n\n          fire_on = Array(options[:on])\n          assert_valid_transaction_action(fire_on)\n          options[:if] = [\n            -> { transaction_include_any_action?(fire_on) },\n            *options[:if]\n          ]\n        end\n\n        # Asserts that the given actions are valid for after_commit\n        # and after_rollback callbacks.\n        #\n        # @param [ Array<Symbol> ] actions Actions to be checked.\n        # @raise [ ArgumentError ] If any of the actions is not valid.\n        def assert_valid_transaction_action(actions)\n          return unless (actions - CALLBACK_ACTIONS).any?\n\n          raise ArgumentError,\n                \":on conditions for after_commit and after_rollback callbacks have to be one of #{CALLBACK_ACTIONS}\"\n        end\n\n        def transaction_include_any_action?(actions)\n          actions.any? do |action|\n            case action\n            when :create\n              persisted? && previously_new_record?\n            when :update\n              !(previously_new_record? || destroyed?)\n            when :destroy\n              destroyed?\n            end\n          end\n        end\n      end\n\n      private","sourceCodeStart":208,"sourceCodeEnd":244,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/clients/sessions.rb#L208-L244","documentation":"Error \":on conditions for after_commit and after_rollback callbacks have to be one of #{CALLBACK_ACTIONS}\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/clients/sessions.rb:226 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}