-
Notifications
You must be signed in to change notification settings - Fork 57
Open
Labels
app:trigger_engineThis issue or pull request is about astarte_trigger_engine applicationThis issue or pull request is about astarte_trigger_engine applicationbugSomething isn't workingSomething isn't working
Description
Current behavior
Currently, trying to define a trigger using the mustache template on an object aggregated value falis
Example trigger action:
{
"http_post_url": "http://hello.world.ai",
"template": "{{new_value}}",
"template_type": "mustache"
}
Example event:
%ValueChangeEvent{
interface: "org.astarte-platform.genericsensors.ServerOwnedAggregateObj",
path: "/my_path",
old_bson_value: Cyanide.encode!(%{v: %{"enable" => true, "samplingPeriod" => 10}}),
new_bson_value: Cyanide.encode!(%{v: %{"enable" => false, "samplingPeriod" => 11}})
}
Result:
** (ErlangError) Erlang error: :unsupported_term
Reproducing the issue
This is an example of the values available to the mustache template
%{
"__unknown_fields__" => [],
"device_id" => "f0VMRgIBAQAAAAAAAAAAAA",
"event_type" => "value_change_event",
"interface" => "org.astarte-platform.genericsensors.ServerOwnedAggregateObj",
"new_value" => %{"enable" => false, "samplingPeriod" => 11},
"old_value" => %{"enable" => true, "samplingPeriod" => 10},
"path" => "/my_path",
"realm" => "realm579",
"trigger_name" => "trigger_mustache_2"
}
And this is how bbmustache behaves on IEx
iex(4)> :bbmustache.render("{{a}}", %{"a" => 3}, key_type: :binary)
"3"
iex(5)> :bbmustache.render("{{a}}", %{"a" => %{b: 2}}, key_type: :binary)
** (ErlangError) Erlang error: :unsupported_term
iex(5)> :bbmustache.render("{{a}}", %{"a" => %{"b" => 2}}, key_type: :binary)
** (ErlangError) Erlang error: :unsupported_term
iex(5)>
Metadata
Metadata
Assignees
Labels
app:trigger_engineThis issue or pull request is about astarte_trigger_engine applicationThis issue or pull request is about astarte_trigger_engine applicationbugSomething isn't workingSomething isn't working