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

Unable to PUT or PATCH registered attributes on CPrs entities (that does not exists locally) #4430

Closed
mapedraza opened this issue Sep 26, 2023 · 3 comments
Labels

Comments

@mapedraza
Copy link
Collaborator

mapedraza commented Sep 26, 2023

Bug description
When registering an entity provided from a Context Provider, without creating it, the entity is listed when executing GET /v2/entities/<entityID> but it is not possible to PUT or PATCH the registered attribute.

This particular case is relevant when creating an only actuation entity. This behaviour is expected for all IoT Agents using the IoTA Node LIB version 3.4.0 or higher since no entity is created when provisioning the devices.

How to reproduce it
Steps to reproduce the behavior (as an example)

After creating a device using the IoT Agent JSON, the entity gets registered, but no entity is created after. Then, it is possible to query the entity

curl -L 'http://localhost:1026/v2/entities/Bell:001?options=keyValues' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /'

It returns:

{
    "id": "Bell:001",
    "type": "Bell",
    "ring": ""
}

But it is not possible to PUT or PATCH that entity

curl -L -X PUT 'http://localhost:1026/v2/entities/Bell:001/attrs/ring' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : ""
}'

is returning:

{
    "error": "NotFound",
    "description": "The requested entity has not been found. Check type and id"
}

Expected behavior
Allowing PATCH or PUT to registerd attributes in entities that does not exits locally on the context broker.

Additional Information
Related IoTA Issue:
telefonicaid/iotagent-node-lib#1464

@mapedraza
Copy link
Collaborator Author

After some tests using latests versions of IoTA and Orion, it is possible to put or patch when specifying the entity type as URL parameter as described here: telefonicaid/iotagent-node-lib#1464 (comment)

Take as an example the following request:

curl -L -X PUT 'http://localhost:1026/v2/entities/Bell:001/attrs/ring?type=Bell' \
-H 'fiware-service: openiot' \
-H 'fiware-servicepath: /' \
-H 'Content-Type: application/json' \
-d '{
      "type" : "command",
      "value" : ""
}'

@jason-fox Please, could you verify if it works for you?

@jason-fox
Copy link
Contributor

Yes that works and makes sense.

curl -L -X PUT \
   'http://localhost:1026/v2/entities/urn:ngsi-ld:Bell:001/attrs/ring'

Fails but

curl -L -X PUT \
   'http://localhost:1026/v2/entities/urn:ngsi-ld:Bell:001/attrs/ring?type=Bell'

Succeeds.

This is because the IoT Agent registers the Bell as:

[
    {
        "id": "65a907b164f1d24eb30ce7bd",
        "dataProvided": {
            "entities": [
                {
                    "id": "urn:ngsi-ld:Bell:001",
                    "type": "Bell"
                }
            ],
            "attrs": [ "ring"]
        }
    }
]

Which is for an Entity with id urn:ngsi-ld:Bell:001 and type Bell. At this point in time Orion has no local Entity and therefore the type is unknown unless it is supplied in the request.

@mapedraza
Copy link
Collaborator Author

Ok, so, after this, we can close this issue and telefonicaid/iotagent-node-lib#1465.

The scope of PR telefonicaid/iotagent-node-lib#1551 should change to reflect latest conclusions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants