{"record":{"id":"b213b6fb74e88dfd","repo":"fetlife/rollout","slug":"context-must-be-a-hash","errorCode":null,"errorMessage":"context must be a Hash","messagePattern":"context must be a Hash","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/rollout/logging.rb","lineNumber":160,"sourceCode":"          raise ArgumentError, \"Invalid log event: #{event}\"\n        end\n\n        expected_arity = method(event).arity\n        unless args.count == expected_arity\n          raise(\n            ArgumentError,\n            \"Invalid number of arguments for event '#{event}': expected #{expected_arity} but got #{args.count}\",\n          )\n        end\n\n        public_send(event, *args)\n      end\n\n      CONTEXT_THREAD_KEY = :rollout_logging_context\n      WITHOUT_THREAD_KEY = :rollout_logging_disabled\n\n      def with_context(context)\n        raise ArgumentError, \"context must be a Hash\" unless context.is_a?(Hash)\n        raise ArgumentError, \"block is required\" unless block_given?\n\n        Thread.current[CONTEXT_THREAD_KEY] = context\n        yield\n      ensure\n        Thread.current[CONTEXT_THREAD_KEY] = nil\n      end\n\n      def current_context\n        Thread.current[CONTEXT_THREAD_KEY] || {}\n      end\n\n      def without\n        Thread.current[WITHOUT_THREAD_KEY] = true\n        yield\n      ensure\n        Thread.current[WITHOUT_THREAD_KEY] = nil\n      end","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/fetlife/rollout/blob/bd318a94887aab2bda25f89d44825a42a573ff34/lib/rollout/logging.rb#L142-L178","documentation":"Error \"context must be a Hash\" thrown in fetlife/rollout.","triggerScenarios":"Thrown at lib/rollout/logging.rb:160 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a Hash to with_context, e.g. Rollout::Logging.with_context({ user_id: 1 }) { ... }.","Convert the value to a Hash before calling: with_context(context.to_h) { ... }.","Verify no nil or non-Hash value (string, array) is passed as the context argument."],"exampleFix":"Rollout::Logging.with_context({ user_id: user.id }) do\n  rollout.activate(:new_ui)\nend","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bd318a94887aab2bda25f89d44825a42a573ff34","analyzedAt":"2026-08-23T16:22:44.185Z","schemaVersion":2},"datasetVersion":"2026-08-23T21:17:23.414Z"}