Skip to content

Commit 5cc79b3

Browse files
committed
chore: forward-port release-1.2
Signed-off-by: frossq <francesco.asquini@secomind.com>
2 parents ed0f131 + 29fccd6 commit 5cc79b3

File tree

3 files changed

+59
-4
lines changed

3 files changed

+59
-4
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [1.3.0] - Unreleased
9+
10+
### Fixed
11+
12+
- Insufficient validation for conflicting options in interface aggregate mappings
13+
[#1072](https://github.com/astarte-platform/astarte/issues/1072)
14+
815
## [1.3.0-rc.1] - 2026-01-23
916

1017
### Fixed
@@ -21,6 +28,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2128
- Add events for device deletion started and finished.
2229
- Add event for device registration.
2330

31+
## [1.2.1-rc.0] - 2025-08-22
32+
### Added
33+
- Allow `to_int` in custom enum types to be called with valid integers
34+
- Allow `from_int` in custom enum types to be called with valid atoms
35+
- Expose a custom `@type` for all structs
36+
- Implement json encoder for `IncomingIntrospectionEvent`
37+
2438
## [1.2.0] - 2024-07-01
2539

2640
## [1.2.0-rc.0] - 2024-05-28

lib/astarte_core/interface.ex

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,17 @@ defmodule Astarte.Core.Interface do
218218

219219
defp validate_all_mappings_have_same_attributes(changeset) do
220220
mappings = get_field(changeset, :mappings, [])
221-
aggregation = get_field(changeset, :aggregation, [])
221+
aggregation = get_field(changeset, :aggregation, :individual)
222222

223223
if aggregation == :object and mappings != [] do
224224
%Mapping{
225225
retention: retention,
226226
reliability: reliability,
227227
expiry: expiry,
228228
allow_unset: allow_unset,
229-
explicit_timestamp: explicit_timestamp
229+
explicit_timestamp: explicit_timestamp,
230+
database_retention_policy: database_retention_policy,
231+
database_retention_ttl: database_retention_ttl
230232
} = List.first(mappings)
231233

232234
all_same_attributes =
@@ -236,12 +238,16 @@ defmodule Astarte.Core.Interface do
236238
reliability: mapping_reliability,
237239
expiry: mapping_expiry,
238240
allow_unset: mapping_allow_unset,
239-
explicit_timestamp: mapping_explicit_timestamp
241+
explicit_timestamp: mapping_explicit_timestamp,
242+
database_retention_policy: mapping_database_retention_policy,
243+
database_retention_ttl: mapping_database_retention_ttl
240244
} = mapping
241245

242246
retention == mapping_retention and reliability == mapping_reliability and
243247
expiry == mapping_expiry and allow_unset == mapping_allow_unset and
244-
explicit_timestamp == mapping_explicit_timestamp
248+
explicit_timestamp == mapping_explicit_timestamp and
249+
database_retention_policy == mapping_database_retention_policy and
250+
database_retention_ttl == mapping_database_retention_ttl
245251
end)
246252

247253
unless all_same_attributes do

test/astarte_core/interface_test.exs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,31 @@ defmodule Astarte.Core.InterfaceTest do
123123
}
124124
"""
125125

126+
@conflicting_properties_aggregated_datastreams """
127+
{
128+
"interface_name": "com.secomind.Hemera.DeviceValues",
129+
"version_major": 1,
130+
"version_minor": 0,
131+
"type": "datastream",
132+
"ownership": "producer",
133+
"aggregation": "object",
134+
"mappings": [
135+
{
136+
"endpoint": "/value/first",
137+
"type": "integer",
138+
"database_retention_policy": "use_ttl",
139+
"database_retention_ttl": 600
140+
},
141+
{
142+
"endpoint": "/value/second",
143+
"type": "integer",
144+
"database_retention_policy": "use_ttl",
145+
"database_retention_ttl": 300
146+
}
147+
]
148+
}
149+
"""
150+
126151
test "aggregated datastream interface deserialization" do
127152
{:ok, params} = Jason.decode(@aggregated_datastream_interface_json)
128153

@@ -212,6 +237,16 @@ defmodule Astarte.Core.InterfaceTest do
212237
assert %Ecto.Changeset{valid?: false, errors: [endpoint: _]} = mapping_changeset
213238
end
214239

240+
test "attributes mismatch in aggregate mappings" do
241+
{:ok, params} = Jason.decode(@conflicting_properties_aggregated_datastreams)
242+
243+
assert %Ecto.Changeset{
244+
valid?: false,
245+
errors: [mappings: _]
246+
} =
247+
Interface.changeset(%Interface{}, params)
248+
end
249+
215250
test "invalid interface name" do
216251
params = %{
217252
"interface_name" => "notok; DROP KEYSPACE astarte;//",

0 commit comments

Comments
 (0)