From ae3d6cb4b504b17f3e3f961fad62afa6c0940f0a Mon Sep 17 00:00:00 2001 From: Newroz Arslan Date: Wed, 17 Sep 2025 06:31:54 +0300 Subject: [PATCH 1/3] Fix handling of commit-hash versions in peer_properties --- lib/connection/handler.ex | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/connection/handler.ex b/lib/connection/handler.ex index ecd9221..7b668ef 100644 --- a/lib/connection/handler.ex +++ b/lib/connection/handler.ex @@ -122,9 +122,11 @@ defmodule RabbitMQStream.Connection.Handler do # We need to extract the base version from the version string so we can compare # make decisions based on the version of the server. version = - ~r/(\d+)\.(\d+)\.(\d+)/ - |> Regex.run(response.data.peer_properties["version"], capture: :all_but_first) - |> Enum.map(&String.to_integer/1) + case Regex.run(~r/(\d+)\.(\d+)\.(\d+)/, response.data.peer_properties["version"], capture: :all_but_first) do + # fallback for commit-hashes + nil -> [3, 13, 0] + matches -> Enum.map(matches, &String.to_integer/1) + end peer_properties = Map.put(response.data.peer_properties, "base-version", version) From c49f7683f20ae1a4a61be5b3b30ace77e24dfaee Mon Sep 17 00:00:00 2001 From: Victor Gaiva <13839490+VictorGaiva@users.noreply.github.com> Date: Wed, 17 Sep 2025 23:43:42 -0300 Subject: [PATCH 2/3] refactor: Version checking using `Version.parse!` --- lib/connection/handler.ex | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/lib/connection/handler.ex b/lib/connection/handler.ex index 7b668ef..51a78fa 100644 --- a/lib/connection/handler.ex +++ b/lib/connection/handler.ex @@ -121,14 +121,9 @@ defmodule RabbitMQStream.Connection.Handler do # We need to extract the base version from the version string so we can compare # make decisions based on the version of the server. - version = - case Regex.run(~r/(\d+)\.(\d+)\.(\d+)/, response.data.peer_properties["version"], capture: :all_but_first) do - # fallback for commit-hashes - nil -> [3, 13, 0] - matches -> Enum.map(matches, &String.to_integer/1) - end + base_version = Version.parse(response.data.peer_properties["version"]) - peer_properties = Map.put(response.data.peer_properties, "base-version", version) + peer_properties = Map.put(response.data.peer_properties, "base-version", base_version) %{conn | peer_properties: peer_properties} |> Helpers.push_internal(:request, :sasl_handshake) @@ -172,7 +167,7 @@ defmodule RabbitMQStream.Connection.Handler do %Connection{peer_properties: %{"base-version" => version}} = conn, %Response{command: :open} = response ) - when version < [3, 13] do + when [version.major, version.minor] < [3, 13] do Logger.debug("Successfully opened connection with vhost: \"#{conn.options[:vhost]}\"") for request <- conn.connect_requests do @@ -188,7 +183,7 @@ defmodule RabbitMQStream.Connection.Handler do %Connection{peer_properties: %{"base-version" => version}} = conn, %Response{command: :open} = response ) - when version >= [3, 13] do + when [version.major, version.minor] >= [3, 13] do Logger.debug( "Successfully opened connection with vhost: \"#{conn.options[:vhost]}\". Initiating command version exchange." ) From f2bdc5a516a2911bfbd384dc26c6c1499cd38f9e Mon Sep 17 00:00:00 2001 From: Victor Gaiva <13839490+VictorGaiva@users.noreply.github.com> Date: Wed, 17 Sep 2025 23:46:25 -0300 Subject: [PATCH 3/3] hotfix: Use the correct module --- lib/connection/handler.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/connection/handler.ex b/lib/connection/handler.ex index 51a78fa..1921823 100644 --- a/lib/connection/handler.ex +++ b/lib/connection/handler.ex @@ -121,7 +121,7 @@ defmodule RabbitMQStream.Connection.Handler do # We need to extract the base version from the version string so we can compare # make decisions based on the version of the server. - base_version = Version.parse(response.data.peer_properties["version"]) + base_version = Version.parse!(response.data.peer_properties["version"]) peer_properties = Map.put(response.data.peer_properties, "base-version", base_version)