fetlife/rollout · error · ArgumentError

block is required

Error message

block is required

What it means

Error "block is required" thrown in fetlife/rollout.

Source

Thrown at lib/rollout/logging.rb:161

        end

        expected_arity = method(event).arity
        unless args.count == expected_arity
          raise(
            ArgumentError,
            "Invalid number of arguments for event '#{event}': expected #{expected_arity} but got #{args.count}",
          )
        end

        public_send(event, *args)
      end

      CONTEXT_THREAD_KEY = :rollout_logging_context
      WITHOUT_THREAD_KEY = :rollout_logging_disabled

      def with_context(context)
        raise ArgumentError, "context must be a Hash" unless context.is_a?(Hash)
        raise ArgumentError, "block is required" unless block_given?

        Thread.current[CONTEXT_THREAD_KEY] = context
        yield
      ensure
        Thread.current[CONTEXT_THREAD_KEY] = nil
      end

      def current_context
        Thread.current[CONTEXT_THREAD_KEY] || {}
      end

      def without
        Thread.current[WITHOUT_THREAD_KEY] = true
        yield
      ensure
        Thread.current[WITHOUT_THREAD_KEY] = nil
      end

View on GitHub (pinned to bd318a9488)

Solutions

  1. Call with_context with a block: Rollout::Logging.with_context({}) { ... }.
  2. Move the code that must run under the context into a do...end block passed to with_context.

Example fix

Rollout::Logging.with_context({ request_id: id }) do
  rollout.activate(:feature)
end

When it happens

Trigger: Thrown at lib/rollout/logging.rb:161 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of fetlife/rollout@bd318a9488 (2026-08-23). Data as JSON: /api/errors/3ed696aa3c17a76c. Report an issue: GitHub.