From 7ec227174b86feac81b5cd764f73346477b385e2 Mon Sep 17 00:00:00 2001 From: Ari Karim Date: Thu, 18 Dec 2025 14:08:01 +0300 Subject: [PATCH 1/3] feat: Add setter for ORM configuration. --- lib/rabbit_carrots/configuration.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/rabbit_carrots/configuration.rb b/lib/rabbit_carrots/configuration.rb index acc7a9b..29a2fd6 100644 --- a/lib/rabbit_carrots/configuration.rb +++ b/lib/rabbit_carrots/configuration.rb @@ -23,5 +23,9 @@ module RabbitCarrots def orm @orm ||= :activerecord end + + def orm=(value) + @orm = value + end end end From c673d7e5a1880adf7fc9546473b37d9e28d22dcc Mon Sep 17 00:00:00 2001 From: Ari Karim Date: Thu, 18 Dec 2025 14:08:31 +0300 Subject: [PATCH 2/3] chore: Bump gem version to 1.0.5. --- lib/rabbit_carrots/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/rabbit_carrots/version.rb b/lib/rabbit_carrots/version.rb index a05e114..4ae5052 100644 --- a/lib/rabbit_carrots/version.rb +++ b/lib/rabbit_carrots/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RabbitCarrots - VERSION = '1.0.4' + VERSION = '1.0.5' end From 0a0ef429c00731aaad8803128b6c5545300342df Mon Sep 17 00:00:00 2001 From: Ari Karim Date: Thu, 18 Dec 2025 15:47:52 +0300 Subject: [PATCH 3/3] fix: Ensure message payloads are UTF-8 encoded before logging and update gem version. --- lib/rabbit_carrots/core.rb | 14 ++++++++++++++ lib/rabbit_carrots/version.rb | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/rabbit_carrots/core.rb b/lib/rabbit_carrots/core.rb index c77f286..43059d1 100644 --- a/lib/rabbit_carrots/core.rb +++ b/lib/rabbit_carrots/core.rb @@ -92,19 +92,24 @@ module RabbitCarrots handler_class.handle!(channel, delivery_info, properties, payload) channel.ack(delivery_info.delivery_tag, false) rescue RabbitCarrots::EventHandlers::Errors::NackMessage, JSON::ParserError => _e + payload = encode_payload(payload) logger.warn "Nacked message: #{payload}" channel.nack(delivery_info.delivery_tag, false, false) rescue RabbitCarrots::EventHandlers::Errors::NackAndRequeueMessage => _e + payload = encode_payload(payload) logger.warn "Nacked and Requeued message: #{payload}" channel.nack(delivery_info.delivery_tag, false, true) rescue self.class.database_agnostic_not_null_violation, self.class.database_agnostic_record_invalid => e + payload = encode_payload(payload) logger.warn "Null constraint or Invalid violation: #{payload}. Error: #{e.message}" channel.ack(delivery_info.delivery_tag, false) rescue self.class.database_agnostic_connection_not_established => e + payload = encode_payload(payload) logger.warn "Error connection not established to the database: #{payload}. Error: #{e.message}" sleep 3 channel.nack(delivery_info.delivery_tag, false, true) rescue StandardError => e + payload = encode_payload(payload) logger.error "Error handling message: #{payload}. Error: #{e.message}" sleep 3 channel.nack(delivery_info.delivery_tag, false, true) @@ -137,5 +142,14 @@ module RabbitCarrots adapter.instance_variable_set(:@logger, logger) adapter end + + def encode_payload(payload) + payload.encode( + 'UTF-8', + invalid: :replace, + undef: :replace, + replace: '' + ) + end end end diff --git a/lib/rabbit_carrots/version.rb b/lib/rabbit_carrots/version.rb index 4ae5052..6fd40c2 100644 --- a/lib/rabbit_carrots/version.rb +++ b/lib/rabbit_carrots/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module RabbitCarrots - VERSION = '1.0.5' + VERSION = '1.0.6' end