telefonicaid / iotagent-node-lib

Module to enable IoT Agent developers to build custom agents for their devices that can easily connect to NGSI Context Brokers
https://iotagent-node-lib.rtfd.io/
GNU Affero General Public License v3.0
60 stars 85 forks source link

`entityNameExpr` allows invalid Orion entityID #1477

Closed mapedraza closed 10 months ago

mapedraza commented 10 months ago

IoT Agent Node Lib version the issue has been seen with

3.4.0

Bound or port used (API interaction)

Northbound (Provision API and NGSI Interactions)

NGSI version

NGSIv2

Are you running a container?

Yes, I am using a contaner (Docker, Kubernetes...)

Image type

None

Expected behaviour you didn't see

No response

Unexpected behaviour you saw

When using expressions that results into an integer or boolean, the IoTA can build an invalid NGSv2 payload:

When defining a group like this and using a number ID (like 123)

{
  "attributes": [
  ],
  "resource": "/iot/json",
  "apikey": "123456789",
  "type": "mytype",
  "service": "srv",
  "subservice": "/subsrv",
  "expressionLanguage": "jexl",
  "entityNameExp": "id",
  "__v": 0
}

The payload is:

{
   "ID":123
   ...
}

Steps to reproduce the problem

No response

Configs

environment:
    - "IOTA_CB_HOST=orion"
    - "IOTA_CB_PORT=1026"
    - "IOTA_NORTH_PORT=4041"
    - "IOTA_REGISTRY_TYPE=mongodb"
    - "IOTA_MONGO_HOST=mongodb"
    - "IOTA_MONGO_PORT=27017"
    - "IOTA_MONGO_DB=iotagent-json"
    - "IOTA_HTTP_PORT=7896"
    - "IOTA_PROVIDER_URL=http://iot-agent:4041"

Log output

No response

AlvaroVega commented 10 months ago

duplicated https://github.com/telefonicaid/iotagent-node-lib/issues/1476 ?

mapedraza commented 10 months ago

Yes, I close this issue