FIWARE / context.Orion-LD

Context Broker and CEF building block for context data management which supports both the NGSI-LD and the NGSI-v2 APIs
https://www.etsi.org/deliver/etsi_gs/CIM/001_099/009/01.06.01_60/gs_CIM009v010601p.pdf
GNU Affero General Public License v3.0
51 stars 43 forks source link

Subscription, selected attributes missing in notification #1567

Open FR-ADDIX opened 9 months ago

FR-ADDIX commented 9 months ago

If I create a subscription with a selection of attributes to be sent that is to send the notification to an endpoint, only the ID and the type are transmitted. However, the selected attributes are missing completely.

Has the syntax changed for "attributes"?

orion-ld Version 1.4.0 1.5.1 and 1.6.0

REQUEST / SUBSCRIBTION

{
    "id": "urn:ngsi-ld:subscription:2f15ba0c-d48f-11ee-87a4-5a031afc16c6",
    "type": "Subscription",
    "subscriptionName": "KielMobilApp:AirQualityObserved mit Attributen",
    "description": "Notification ein neuer AirQualityObserved an KielMobil App",
    "entities": [
        {
            "id": "urn:ngsi-ld:AirQualityObserved:Umweltbundesamt:DESH057",
            "type": "AirQualityObserved"
        }
    ],
    "watchedAttributes": [
        "dateObserved"
    ],
    "status": "active",
    "isActive": true,
    "notification": {
        "attributes": [
            "name",
            "dateObserved",
            "address",
            "source",
            "description",
            "pm10"
        ],
        "format": "normalized",
        "endpoint": {
            "uri": "http://nrld20.fiware.svc/appkiel",
            "accept": "application/json"
        },
        "status": "ok",
        "timesSent": 1,
        "lastNotification": "2024-02-26T10:14:10.816Z",
        "lastSuccess": "2024-02-26T10:14:10.816Z"
    },
    "origin": "cache"
}

RESULT

{
    "id": "urn:ngsi-ld:Notification:d4d9f07a-d48f-11ee-9932-26575acf9489",
    "type": "Notification",
    "subscriptionId": "urn:ngsi-ld:subscription:2f15ba0c-d48f-11ee-87a4-5a031afc16c6",
    "notifiedAt": "2024-02-26T10:14:31.128Z",
    "data": [
        {
            "id": "urn:ngsi-ld:AirQualityObserved:Umweltbundesamt:DESH057",
            "type": "AirQualityObserved"
        }
    ]
}
kzangeli commented 8 months ago

This should work as always. Please make sure t hat the entity "urn:ngsi-ld:Notification:d4d9f07a-d48f-11ee-9932-26575acf9489" actually has at least one of the attributes in the list.

And especially, check the long names, never mind the short names. Look closely at the @context used when creating the subscription and the @context used when creating/updating the entities.

Might be there's a mismatch and the longnames differ => not the same attributes

kzangeli commented 8 months ago

That said, it might be a bug. I'll look into it once you swear you haven't mixed up your @context :)))

FR-ADDIX commented 8 months ago

This is of course the same context, as I get all the data without the "attributes" restriction.

kzangeli commented 8 months ago

This is of course the same context, as I get all the data without the "attributes" restriction.

Well, if you don't give the "attributes" field, the entire entity is included. If you do give the "attributes" field, then it works as a projection and only those attributes included in "attributes" are included in the notification. Entity Id and Type are always included - those two are not considered attributes. So, again, are you sure you have the right @context?

It would be easy enough to look at the subscription inside mongo. And then compare the longnames of the subscription with the longnames of the attributes of the entities.

FR-ADDIX commented 8 months ago

ok i will check it