Engineering-Research-and-Development / iotagent-opcua

IoT Agent for OPC UA protocol
https://iotagent-opcua.rtfd.io/
GNU Affero General Public License v3.0
41 stars 21 forks source link

Devices with empty device_id are getting created #83

Closed Anupamskd7 closed 1 year ago

Anupamskd7 commented 1 year ago

Description:

Provisioning a device on the IoTAgent OPC UA with blank device_id gets registered.

Steps to reproduce:

Send a device provisioning request to the 4001 port of IoTAgent OPC UA with blank device_id as follows:

{
    "devices": [
        {
            "device_id": "",
            "entity_name": "urn:ngsi-ld:Device:age09_Car",
            "entity_type": "Device",
            "attributes": [
                {
                    "object_id": "ns=3;s=EngineBrake",
                    "name": "EngineBrake",
                    "type": "Number"
                },
                {
                    "object_id": "ns=3;s=Acceleration",
                    "name": "Acceleration",
                    "type": "Number"
                },
                {
                    "object_id": "ns=3;s=EngineStopped",
                    "name": "EngineStopped",
                    "type": "Boolean"
                }
]}]}

Expected Output:

{"name":"MISSING_ATTRIBUTES","message":"The request was not well formed:Missing attributes: [\"device_id\"]"}

Actual Output:

201 Created

Devices GET Output:

{
    "count": 1,
    "devices": [
        {
            "device_id": "",
            "service": "openiot5",
            "service_path": "/demo",
            "entity_name": "urn:ngsi-ld:Device:age09_Car",
            "entity_type": "Device",
            "attributes": [
                {
                    "object_id": "ns=3;s=EngineBrake",
                    "name": "EngineBrake",
                    "type": "Number"
                },
                {
                    "object_id": "ns=3;s=Acceleration",
                    "name": "Acceleration",
                    "type": "Number"
                },
                {
                    "object_id": "ns=3;s=EngineStopped",
                    "name": "EngineStopped",
                    "type": "Boolean"
                }
            ],
            "lazy": [],
            "commands": [
                {
                    "object_id": "Error",
                    "name": "Error",
                    "type": "command"
                },
                {
                    "object_id": "Stop",
                    "name": "Stop",
                    "type": "command"
                },
                {
                    "object_id": "Accelerate",
                    "name": "Accelerate",
                    "type": "command"
                }
            ],
            "static_attributes": []
        }
    ]
}

Affected Product Version:

IoTAgent OPC UA latest

Environment details (with versions):

OS: Centos 7 Env (Docker/K8s): Both Docker & K8S

manfredipist commented 1 year ago

Dear @Anupamskd7 , thanks for the detailed report, we will notify the problem to the underlying library on top of which iotagent-opcua is built. Best Regards