Skip to content

Commit

Permalink
Merge pull request #852 from Annopaolo/binaryblobs-are-stored-correctly
Browse files Browse the repository at this point in the history
DUP: decode and store binaryblob values correctly
  • Loading branch information
rbino authored Oct 6, 2023
2 parents 4762e1e + 0bd8006 commit 5134422
Show file tree
Hide file tree
Showing 9 changed files with 18 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
Fix [#149](https://github.com/astarte-platform/astarte/issues/149).
- [astarte-realm_management] Do not crash when some synchronous operations
(e.g. interface install) succeed.
- [astarte_data_updater_plant] Don't crash when handling incoming `binaryblob` values
(see https://github.com/astarte-platform/astarte_core/issues/95).

## [1.1.0] - 2023-06-20
### Fixed
Expand Down
2 changes: 1 addition & 1 deletion apps/astarte_appengine_api/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ defmodule Astarte.AppEngine.API.Mixfile do

defp astarte_required_modules(_) do
[
{:astarte_core, "~> 1.1"},
{:astarte_core, "~> 1.1.1"},
{:astarte_data_access,
github: "astarte-platform/astarte_data_access", branch: "release-1.1"},
{:astarte_rpc, "~> 1.1"}
Expand Down
2 changes: 1 addition & 1 deletion apps/astarte_appengine_api/mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"amqp": {:hex, :amqp, "2.1.1", "ad8dec713ba885afffffcb81feb619fe7cfcbcabe9377ab65ab7a110bd4f43a0", [:mix], [{:amqp_client, "~> 3.8.0", [hex: :amqp_client, repo: "hexpm", optional: false]}], "hexpm", "b6d926770e4508e30e3e9e476c57b6c8aeda44f7715663bdc38935620ce5be6f"},
"amqp_client": {:hex, :amqp_client, "3.8.14", "7569517aefb47e0d1c41bca2f4768dc8a2d88487daf7819fecca0d78943f293c", [:make, :rebar3], [{:rabbit_common, "3.8.14", [hex: :rabbit_common, repo: "hexpm", optional: false]}], "hexpm", "e5ba3ac18abbe34a1d990a6bcac25633dc7061ab8f8d101c7dcff97f49f4c523"},
"astarte_core": {:hex, :astarte_core, "1.1.0", "de3ec13feba526ac7ffffe34e822507d9b2ef27c5ca9176c8f81fc32f5fb82ed", [:mix], [{:cyanide, "~> 2.0", [hex: :cyanide, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_morph, "~> 0.1.23", [hex: :ecto_morph, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "4b6175ec088cf6096fcfc0d02d86b67cf305b42750cad145a64c8bf7f1eabd91"},
"astarte_core": {:hex, :astarte_core, "1.1.1", "165b86cc965f51586e3141add9433845659a05373eb04e85db2837473c59cab5", [:mix], [{:cyanide, "~> 2.0", [hex: :cyanide, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_morph, "~> 0.1.23", [hex: :ecto_morph, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "9c36070dc90b5f706d41d25d35f090f1c02ce67f01b2ecb4d5bccf0c6254beba"},
"astarte_data_access": {:git, "https://github.com/astarte-platform/astarte_data_access.git", "c9d36fb005131fc0938ae5712c1ebc23746be528", [branch: "release-1.1"]},
"astarte_rpc": {:hex, :astarte_rpc, "1.1.0", "61cae0468df48c53cef3a279282aa07b2d758427b5a3c2af8a5993c8f86f9cdf", [:mix], [{:amqp, "~> 2.1", [hex: :amqp, repo: "hexpm", optional: false]}, {:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}, {:skogsra, "~> 2.2", [hex: :skogsra, repo: "hexpm", optional: false]}], "hexpm", "1f0933cbd4a8ca8d5624b093abcfc68ef4df27cb38849368072a0d65ffc9a597"},
"castore": {:hex, :castore, "0.1.16", "2675f717adc700475345c5512c381ef9273eb5df26bdd3f8c13e2636cf4cc175", [:mix], [], "hexpm", "28ed2c43d83b5c25d35c51bc0abf229ac51359c170cba76171a462ced2e4b651"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,13 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater.Impl do
ValueType.validate_value(expected_type, value)
end

# Explicitly match on all structs to avoid pattern matching them as maps below
# From Cyanide 2.0, binaries are decoded as %Cyanide.Binary{}
def validate_value_type(expected_type, %Cyanide.Binary{} = value) do
%Cyanide.Binary{subtype: _subtype, data: bin} = value
validate_value_type(expected_type, bin)
end

# Explicitly match on all other structs to avoid pattern matching them as maps below
def validate_value_type(_expected_type, %_{} = _unsupported_struct) do
{:error, :unexpected_value_type}
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,8 @@ defmodule Astarte.DataUpdaterPlant.DataUpdater.Queries do
DateTime.to_unix(datetime, :millisecond)
end

defp to_db_friendly_type({_subtype, bin}) do
# From Cyanide 2.0, binaries are decoded as %Cyanide.Binary{}
defp to_db_friendly_type(%Cyanide.Binary{subtype: _subtype, data: bin}) do
bin
end

Expand Down
2 changes: 1 addition & 1 deletion apps/astarte_data_updater_plant/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ defmodule Astarte.DataUpdaterPlant.Mixfile do

defp astarte_required_modules(_) do
[
{:astarte_core, github: "astarte-platform/astarte_core", branch: "release-1.1"},
{:astarte_core, "~> 1.1.1"},
{:astarte_data_access,
github: "astarte-platform/astarte_data_access", branch: "release-1.1"},
{:astarte_rpc, "~> 1.1"}
Expand Down
4 changes: 2 additions & 2 deletions apps/astarte_data_updater_plant/mix.lock
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%{
"amqp": {:hex, :amqp, "2.1.1", "ad8dec713ba885afffffcb81feb619fe7cfcbcabe9377ab65ab7a110bd4f43a0", [:mix], [{:amqp_client, "~> 3.8.0", [hex: :amqp_client, repo: "hexpm", optional: false]}], "hexpm", "b6d926770e4508e30e3e9e476c57b6c8aeda44f7715663bdc38935620ce5be6f"},
"amqp_client": {:hex, :amqp_client, "3.8.14", "7569517aefb47e0d1c41bca2f4768dc8a2d88487daf7819fecca0d78943f293c", [:make, :rebar3], [{:rabbit_common, "3.8.14", [hex: :rabbit_common, repo: "hexpm", optional: false]}], "hexpm", "e5ba3ac18abbe34a1d990a6bcac25633dc7061ab8f8d101c7dcff97f49f4c523"},
"astarte_core": {:git, "https://github.com/astarte-platform/astarte_core.git", "21d3b7cac1c237c094e68fee7f4a0937768fd97c", [branch: "release-1.1"]},
"astarte_data_access": {:git, "https://github.com/astarte-platform/astarte_data_access.git", "bae820c0cd6d308940d64c7c1c784071bf52f57d", [branch: "release-1.1"]},
"astarte_core": {:hex, :astarte_core, "1.1.1", "165b86cc965f51586e3141add9433845659a05373eb04e85db2837473c59cab5", [:mix], [{:cyanide, "~> 2.0", [hex: :cyanide, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_morph, "~> 0.1.23", [hex: :ecto_morph, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "9c36070dc90b5f706d41d25d35f090f1c02ce67f01b2ecb4d5bccf0c6254beba"},
"astarte_data_access": {:git, "https://github.com/astarte-platform/astarte_data_access.git", "d87fb3cc2823a7b53b73a94d31edf549b1a5b17f", [branch: "release-1.1"]},
"astarte_rpc": {:hex, :astarte_rpc, "1.1.0", "61cae0468df48c53cef3a279282aa07b2d758427b5a3c2af8a5993c8f86f9cdf", [:mix], [{:amqp, "~> 2.1", [hex: :amqp, repo: "hexpm", optional: false]}, {:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}, {:skogsra, "~> 2.2", [hex: :skogsra, repo: "hexpm", optional: false]}], "hexpm", "1f0933cbd4a8ca8d5624b093abcfc68ef4df27cb38849368072a0d65ffc9a597"},
"castore": {:hex, :castore, "0.1.16", "2675f717adc700475345c5512c381ef9273eb5df26bdd3f8c13e2636cf4cc175", [:mix], [], "hexpm", "28ed2c43d83b5c25d35c51bc0abf229ac51359c170cba76171a462ced2e4b651"},
"certifi": {:hex, :certifi, "2.9.0", "6f2a475689dd47f19fb74334859d460a2dc4e3252a3324bd2111b8f0429e7e21", [:rebar3], [], "hexpm", "266da46bdb06d6c6d35fde799bcb28d36d985d424ad7c08b5bb48f5b5cdd4641"},
Expand Down
2 changes: 1 addition & 1 deletion apps/astarte_trigger_engine/mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ defmodule Astarte.TriggerEngine.Mixfile do

defp astarte_required_modules(_) do
[
{:astarte_core, "~> 1.1"},
{:astarte_core, "~> 1.1.1"},
{:astarte_data_access, "~> 1.1"}
]
end
Expand Down
2 changes: 1 addition & 1 deletion apps/astarte_trigger_engine/mix.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%{
"amqp": {:hex, :amqp, "2.1.1", "ad8dec713ba885afffffcb81feb619fe7cfcbcabe9377ab65ab7a110bd4f43a0", [:mix], [{:amqp_client, "~> 3.8.0", [hex: :amqp_client, repo: "hexpm", optional: false]}], "hexpm", "b6d926770e4508e30e3e9e476c57b6c8aeda44f7715663bdc38935620ce5be6f"},
"amqp_client": {:hex, :amqp_client, "3.8.14", "7569517aefb47e0d1c41bca2f4768dc8a2d88487daf7819fecca0d78943f293c", [:make, :rebar3], [{:rabbit_common, "3.8.14", [hex: :rabbit_common, repo: "hexpm", optional: false]}], "hexpm", "e5ba3ac18abbe34a1d990a6bcac25633dc7061ab8f8d101c7dcff97f49f4c523"},
"astarte_core": {:hex, :astarte_core, "1.1.0", "de3ec13feba526ac7ffffe34e822507d9b2ef27c5ca9176c8f81fc32f5fb82ed", [:mix], [{:cyanide, "~> 2.0", [hex: :cyanide, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_morph, "~> 0.1.23", [hex: :ecto_morph, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "4b6175ec088cf6096fcfc0d02d86b67cf305b42750cad145a64c8bf7f1eabd91"},
"astarte_core": {:hex, :astarte_core, "1.1.1", "165b86cc965f51586e3141add9433845659a05373eb04e85db2837473c59cab5", [:mix], [{:cyanide, "~> 2.0", [hex: :cyanide, repo: "hexpm", optional: false]}, {:ecto, "~> 3.4", [hex: :ecto, repo: "hexpm", optional: false]}, {:ecto_morph, "~> 0.1.23", [hex: :ecto_morph, repo: "hexpm", optional: false]}, {:elixir_uuid, "~> 1.2", [hex: :elixir_uuid, repo: "hexpm", optional: false]}, {:jason, "~> 1.2", [hex: :jason, repo: "hexpm", optional: false]}, {:protobuf, "~> 0.12", [hex: :protobuf, repo: "hexpm", optional: false]}], "hexpm", "9c36070dc90b5f706d41d25d35f090f1c02ce67f01b2ecb4d5bccf0c6254beba"},
"astarte_data_access": {:hex, :astarte_data_access, "1.1.0", "807677199fde1a53bde55a23fa7fddc6d4bef98d231d414b84fe0068a5c0a918", [:mix], [{:astarte_core, "~> 1.1", [hex: :astarte_core, repo: "hexpm", optional: false]}, {:castore, "~> 0.1.0", [hex: :castore, repo: "hexpm", optional: false]}, {:cqex, "~> 1.0", [hex: :cqex, repo: "hexpm", optional: false]}, {:skogsra, "~> 2.2", [hex: :skogsra, repo: "hexpm", optional: false]}, {:xandra, "~> 0.11", [hex: :xandra, repo: "hexpm", optional: false]}], "hexpm", "3bbdb2a66d43b35d762805e73cc28a95cce4cb27a5a61cb37dabe5faae326f21"},
"bbmustache": {:hex, :bbmustache, "1.11.0", "a6dbfc5cee3e1d7d17aad5f5b8880b4508d974611da8d73e1f6c28bde65d4c47", [:rebar3], [], "hexpm", "7c9cdcf58dc043377ab792a8c7109d8902695fcae3b35c1078a8b38ddcf86e5f"},
"castore": {:hex, :castore, "0.1.18", "deb5b9ab02400561b6f5708f3e7660fc35ca2d51bfc6a940d2f513f89c2975fc", [:mix], [], "hexpm", "61bbaf6452b782ef80b33cdb45701afbcf0a918a45ebe7e73f1130d661e66a06"},
Expand Down

0 comments on commit 5134422

Please sign in to comment.