Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty arrays properties sent as null upon reconnection. #918

Open
sorru94 opened this issue Mar 29, 2024 · 1 comment
Open

Empty arrays properties sent as null upon reconnection. #918

sorru94 opened this issue Mar 29, 2024 · 1 comment
Labels
app:appengine_api This issue or pull request is about astarte_appengine_api application app:data_updater_plant This issue or pull request is about astarte_data_updater_plant application database This issue or pull request is about database (e.g. schema change, queries, support, etc...) user experience This issue is about user experience

Comments

@sorru94
Copy link
Contributor

sorru94 commented Mar 29, 2024

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:

08 00 00 00 0a 76 00 00

Which in human readable form is:

{ "v": null }

This has been tested using Astarte v1.1.0.

@Annopaolo Annopaolo added database This issue or pull request is about database (e.g. schema change, queries, support, etc...) user experience This issue is about user experience app:appengine_api This issue or pull request is about astarte_appengine_api application app:data_updater_plant This issue or pull request is about astarte_data_updater_plant application labels Apr 9, 2024
@Annopaolo
Copy link
Collaborator

Annopaolo commented Apr 9, 2024

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}}} 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:appengine_api This issue or pull request is about astarte_appengine_api application app:data_updater_plant This issue or pull request is about astarte_data_updater_plant application database This issue or pull request is about database (e.g. schema change, queries, support, etc...) user experience This issue is about user experience
Projects
Status: No status
Development

No branches or pull requests

2 participants