Kaynağa Gözat

Merge pull request #11563 from kjellwinblad/kjell/fix/release-52/EMQX-10775

fix: update gpb library to fix type error
Kjell Winblad 2 yıl önce
ebeveyn
işleme
7fe704b6dd

+ 1 - 1
apps/emqx_schema_registry/rebar.config

@@ -6,7 +6,7 @@
   {emqx_utils, {path, "../emqx_utils"}},
   {emqx_rule_engine, {path, "../emqx_rule_engine"}},
   {erlavro, {git, "https://github.com/klarna/erlavro.git", {tag, "2.9.8"}}},
-  {gpb, "4.19.7"}
+  {gpb, "4.19.9"}
 ]}.
 
 {shell, [

+ 14 - 1
apps/emqx_schema_registry/test/emqx_schema_registry_SUITE.erl

@@ -42,7 +42,8 @@ sparkplug_tests() ->
     [
         t_sparkplug_decode,
         t_sparkplug_encode,
-        t_sparkplug_decode_encode_with_message_name
+        t_sparkplug_decode_encode_with_message_name,
+        t_sparkplug_encode_float_to_uint64_key
     ].
 
 init_per_suite(Config) ->
@@ -847,6 +848,18 @@ t_sparkplug_encode(_Config) ->
     ?assertMatch(#{data := ExpectedRuleOutput}, Res),
     ok.
 
+t_sparkplug_encode_float_to_uint64_key(_Config) ->
+    %% Test that the following bug is fixed:
+    %% https://emqx.atlassian.net/browse/EMQX-10775
+    %% When one assign a float value to a uint64 key, one should get a
+    %% gpb_type_error and not a badarith error
+    wait_for_sparkplug_schema_registered(),
+    ?assertException(
+        error,
+        {gpb_type_error, _},
+        emqx_rule_funcs:sparkplug_encode(#{<<"seq">> => 1.5})
+    ).
+
 t_sparkplug_decode_encode_with_message_name(_Config) ->
     SQL =
         <<

+ 1 - 0
changes/ee/fix-11563.en.md

@@ -0,0 +1 @@
+Enhanced Google ProtoBuf schema registry support: Now, when assigning a float to an integer using the rule engine functions `schema_encode` or `sparkplug_encode`, a `gpb_type_error` will be raised instead of the previous `badarith` error.

+ 1 - 1
mix.exs

@@ -93,7 +93,7 @@ defmodule EMQXUmbrella.MixProject do
       # in conflict by cowboy_swagger and cowboy
       {:ranch, github: "emqx/ranch", tag: "1.8.1-emqx", override: true},
       # in conflict by grpc and eetcd
-      {:gpb, "4.19.7", override: true, runtime: false},
+      {:gpb, "4.19.9", override: true, runtime: false},
       {:hackney, github: "emqx/hackney", tag: "1.18.1-1", override: true},
       # set by hackney (dependency)
       {:ssl_verify_fun, "1.1.6", override: true},

+ 1 - 1
rebar.config

@@ -53,7 +53,7 @@
     [ {lc, {git, "https://github.com/emqx/lc.git", {tag, "0.3.2"}}}
     , {redbug, "2.0.8"}
     , {covertool, {git, "https://github.com/zmstone/covertool", {tag, "2.0.4.1"}}}
-    , {gpb, "4.19.7"}
+    , {gpb, "4.19.9"}
     , {typerefl, {git, "https://github.com/ieQu1/typerefl", {tag, "0.9.1"}}}
     , {gun, {git, "https://github.com/emqx/gun", {tag, "1.3.9"}}}
     , {ehttpc, {git, "https://github.com/emqx/ehttpc", {tag, "0.4.11"}}}