Open sorru94 opened 6 months ago
This is due to Scylla/Cassandra:
Note that Scylla does not distinguish an empty list from a missing value, thus assigning an empty list ([]) to a list is the same as deleting it.
(source: https://opensource.docs.scylladb.com/stable/cql/types.html)
The same behaviour also appears on datastreams:
❯curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
"http://api.astarte.localhost/appengine/v1/test/devices/$DEVICE/interfaces/$INTERFACE/array_endpoint" \
--data '{"data" :[]}'
{"data":[]}
❯curl -X GET -H "Accept: application/json" -H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
"http://api.astarte.localhost/appengine/v1/test/devices/$DEVICE/interfaces/$INTERFACE"
{"data":{"array_endpoint":{"reception_timestamp":"2024-04-08T16:06:49.116Z","value":null}}}
The issue arises when a server-owned property has been set by a device to an empty array. Upon disconnection and reconnection with a clean session, Astarte sends the server property values to the device. In the case of the empty array, a BSON file containing a
null
value is received. For example, for a string array mapping, the following BSON is received:Which in human readable form is:
This has been tested using Astarte
v1.1.0
.