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

FIWARE ServicePath wildcard not working when listing devices #1555

Closed fbuedding closed 8 months ago

fbuedding commented 8 months ago

IoT Agent Node Lib version the issue has been seen with

3.3.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

normal

Expected behaviour you didn't see

When listing devices with FIWARE ServicePath wildcard, documented here, all devices under the FIWARE service should be returned.

Unexpected behaviour you saw

A response with status code 200 is returned, but with empty device list.

Steps to reproduce the problem

curl --location 'http://localhost:4061/iot/devices' \
--header 'fiware-service: test' \
--header 'fiware-servicepath: /*' \
--data ''

Repsonse:

{
    "count": 0,
    "devices": []
}

Configs

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

Log output

time=2024-01-22T16:08:51.987Z | lvl=DEBUG | corr=61191c50-7558-4aa2-85b7-a474af6400e8 | trans=61191c50-7558-4aa2-85b7-a474af6400e8 | op=IoTAgentNGSI.GenericMiddlewares | from=n/a | srv=crawler | subsrv=/* | msg=Request for path [/iot/devices] from [localhost:4061] | comp=IoTAgent
time=2024-01-22T16:08:52.006Z | lvl=DEBUG | corr=61191c50-7558-4aa2-85b7-a474af6400e8 | trans=61191c50-7558-4aa2-85b7-a474af6400e8 | op=IoTAgentNGSI.DomainControl | from=n/a | srv=crawler | subsrv=/* | msg=response-time: 20 | comp=IoTAgent
fgalan commented 8 months ago

This is actually a docu-bug. That capability has not been ever available in IOTA APIs and the documentation is wrong mentioning it. PR #1556 fixes the documentation.

The ability to query base in service path wildcards belong to Orion Context Broker. Have a look to this section of the documentation: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#service-path (btw, the wilcard is # and not *...).

Thanks for raising this!

fbuedding commented 8 months ago

The ability to query base in service path wildcards belong to Orion Context Broker. Have a look to this section of the documentation: https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md#service-path (btw, the wilcard is # and not *...).

Ah okay thanks! One last question: querying Configs Groups with /* works, will this get removed then?

fgalan commented 8 months ago

querying Configs Groups with /* works, will this get removed then?

Strictly speaking, we have not removed it, as you cannot remove something that never has been there ;)

More precise would be to say: querying query Config Groups with /* is not within the IOTAs functionality.