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

[BUG] in update request /v2/entities/<ID>/attrs/<ATTR_NAME> with two entities with the same id #1387

Closed
iariasleon opened this issue Oct 20, 2015 · 7 comments
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

in update request /v2/entities/<ID>/attrs/<ATTR_NAME> with two entities with the same id
Ex:

create request Nº1

POST http://localhost:1026/v2/entities
Content-Type: application/json
Fiware-Service: test_update_more_entities
Fiware-ServicePath: /test
{"temperature_2": "34", "type": "house", "id": "room"}

create request Nº2

POST http://localhost:1026/v2/entities
Content-Type: application/json
Fiware-Service: test_update_more_entities
Fiware-ServicePath: /test
{"temperature": "67", "type": "home", "id": "room"}

Update by id and attr name

PUT http://localhost:1026/v2/entities/room/attrs/temperature
Content-Type: application/json
Fiware-Service: test_update_more_entities
Fiware-ServicePath: /test
{"value": "80"}

Response

 http code: 204
 content-length: 0

And both entites are updated in mongo

{ "_id" : { "id" : "room", "type" : "house", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "value" : "80", "type" : "", "creDate" : 1445334741, "modDate" : 1445334741}}, "creDate" : 1445334741, "modDate" : 1445334741 }
{ "_id" : { "id" : "room", "type" : "home", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "value" : "80", "type" : "", "creDate" : 1445334741, "modDate" : 1445334741}}, "creDate" : 1445334741, "modDate" : 1445334741 }

Expected

http code: 409 Conflict
{ 
   "error":  "TooManyResults",                                                                 
    "description": "There is more than one entity that match the update. Please refine your query."
}
@iariasleon iariasleon added this to the 0.26.0 milestone Oct 20, 2015
@fgalan fgalan modified the milestones: 0.26.0, 0.27.0, 0.28.0 Oct 28, 2015
@fgalan fgalan modified the milestones: 0.28.0, 0.29.0 Dec 1, 2015
@crbrox crbrox self-assigned this Feb 3, 2016
@crbrox crbrox modified the milestones: 0.28.0, 0.29.0 Feb 3, 2016
@crbrox crbrox mentioned this issue Feb 3, 2016
crbrox added a commit that referenced this issue Feb 4, 2016
@fgalan fgalan reopened this Feb 4, 2016
@fgalan
Copy link
Member

fgalan commented Feb 4, 2016

Fixed in PR #1757. @iariasleon please have a look to check it has been solved.

@fgalan fgalan assigned iariasleon and unassigned crbrox Feb 4, 2016
@iariasleon
Copy link
Contributor Author

Tested with:
version: 0.27.0-next
hash: 2228e50

The same behavior, several entities with the same id (types different), we try to update an attribute data, and the response is without payload (body):

http code: 409
date: Wed, 24 Feb 2016 13:45:25 GMT
connection: Keep-Alive
content-length: 0

@fgalan
Copy link
Member

fgalan commented Feb 24, 2016

Ok, Devel will have a second look on this.

@iariasleon
Copy link
Contributor Author

if we try to update an id uknown, returns without payload too.

http code: 404
date: Wed, 24 Feb 2016 14:09:52 GMT
connection: Keep-Alive
content-length: 0

see #1360

@fgalan
Copy link
Member

fgalan commented Feb 24, 2016

Devel will have a second look on this.

(Not sure if this will be fixed by @crbrox , @kzangeli or me. Thus, let's have this unsasigned by the moment).

@fgalan fgalan modified the milestones: 0.28.0, 1.0.0 Feb 25, 2016
@kzangeli kzangeli self-assigned this Feb 26, 2016
@kzangeli
Copy link
Member

So, after creating a functest for this, the only problem with this issue seems to be the 'missing' payload.
Do we want error payload for 409?
In my opinion, 409 is self-explanatory.
After receiving it, the users should take a look at their request payload.

Perhaps we solve this issue by solving issue #1360? (which would mean this issue can be closed.)

The PR #1757 seems to have it working with /v2/entities/<eid>/attrs/<attr-name>/value, whereas this issue is about /v2/entities/<eid>/attrs/<attr-name>, but we can see in the functest of PR #1757 that there is payload in the 409 ...

@iariasleon
Copy link
Contributor Author

LGTM

http code: 409
date: Tue, 15 Mar 2016 10:45:07 GMT
connection: Keep-Alive
content-type: application/json
content-length: 98
{     
      "error":"TooManyResults",
      "description":"More than one matching entity. Please refine your query"
}

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

No branches or pull requests

4 participants