fiware-orion icon indicating copy to clipboard operation
fiware-orion copied to clipboard

Entity type mandatory to find sole entity when forwarding

Open kzangeli opened this issue 8 years ago • 4 comments

We have found that even though there is only one entity in the system, the entity is not found for forwarding operations, unless its type is explicitly stated in the request using ?type=<typeName>.

This bug was detected using the operation PUT /v2/entities/<eid>/attrs/<attrName>/values but probably applies to other operations involving forwarding as well (as it probably is about the lookup in the list of registrations).

kzangeli avatar Jun 07 '16 15:06 kzangeli

Just to remark that when no registration is in place and the PUT operation is done in CB local values the ?type parameter is not required (except in the case of several entities with the same ID, of course).

fgalan avatar Jun 07 '16 18:06 fgalan

After a closer look we have found that Updates to be forwarded, if they have an empty entity type, they only match with registered entites that also have an empty entity type. This was a decision made long ago, implementing NGSIv1 and it makes some sense, as it avoids 'massive updates' of many entities regardless of type, only matching entity ids.

However, a better approach might be to match 'regardless of entity type' (for Updates with entity type empty) but refuse the update if more than one entity match - and return 409 Conflict in such cases.

Looking at the unittest mongoContextProvidersQueryRequest.noPatternNoType, in mongoContextProvidersQuery_test.cpp, there is a comment about something similar:

* Note also that for E1-A1 there are two possibilities in the registrations database (cr1 and cr2)
* and mongoBackend choses cr1.

In this case a 409 Conflict might be better as well, at least for NGSIv2.

kzangeli avatar Jun 09 '16 09:06 kzangeli

As the priority has lowered, this issue gets out of milestone 1.3.0.

fgalan avatar Jun 09 '16 12:06 fgalan

However, a better approach might be to match 'regardless of entity type' (for Updates with entity type empty) but refuse the update if more than one entity match - and return 409 Conflict in such cases.

Hi, from my point of view this might be a good approach. Has any progress been made in this respect in recent years?

Because in practice it is not always possible to specify a type. I will quote a section of my comment on the issue https://github.com/telefonicaid/fiware-orion/issues/3647:

But in a real world scenario a client usually does not necessarily know about CPr registrations and the general setup of the server-side architecture. He just sends a request to the query endpoint (probably without ?type=<TYPE>) and awaits a result. You wouldn't even be able to intercept and rewrite the request, because the PATCH request in this case provides no information about the addressed entity type. However, of course you could query the type for a named entity in the PATCH request prior to creating a new 'proxy request' from it. But this would notably increase the response time which is less than ideal.

michaeI-s avatar Jun 03 '20 14:06 michaeI-s