telefonicaid / fiware-orion

Context Broker and CEF building block for context data management, providing NGSI interfaces.
https://github.com/telefonicaid/fiware-orion/blob/master/doc/manuals/orion-api.md
GNU Affero General Public License v3.0
210 stars 265 forks source link

[BUG] in POST v2/subscriptions with "q" condition expression but with invalid date values (ISO8601) #1996

Open iariasleon opened 8 years ago

iariasleon commented 8 years ago

in POST v2/subscriptions with "q" condition expression but with invalid date values (ISO8601)

dataset

      | q                                                          |
      |------------------------------------------------------------|
      | my_time<>2016-04-05T14:00:00.00Z                           |
      | my_time>=2r16-04-05T14:00:00.00Z                           |
      | my_time>=-04-05T14:00:00.00Z                               |
      | my_time>=2016_04-05T14:00:00.00Z                           |
      | my_time>=2016-64-05T14:00:00.00Z                           |
      | my_time>=2016--05T14:00:00.00Z                             |
      | my_time>=2016-r4-05T14:00:00.00Z                           |
      | my_time>=2016-04-55T14:00:00.00Z                           |
      | my_time>=2016-04-r5T14:00:00.00Z                           |
      | my_time>=2016-04-T14:00:00.00Z                             |
      | my_time>=2016-04-05K14:00:00.00Z                           |
      | my_time>=2016-04-05T54:00:00.00Z                           |
      | my_time>=2016-04-05Tr4:00:00.00Z                           |
      | my_time>=2016-04-05T:00:00.00Z                             |
      | my_time>=2016-04-05T14;00:00.00Z                           |
      | my_time>=2016-04-05T14:r0:00.00Z                           |
      | my_time>=2016-04-05T14:44:00.00Z                           |
      | my_time>=2016-04-05T14::00.00Z                             |
      | my_time>=2016-04-05T14:10-00.00Z                           |
      | my_time>=2016-04-05T14:10:x0.00Z                           |
      | my_time>=2016-04-05T14:10:0x.00Z                           |
      | my_time>=2016-04-05T14:10:.00Z                             |
      | my_time>=2016-04-05T14:10:00,00Z                           |
      | my_time>=2016-04-05T14:10:00.h00Z                          |
      | my_time>=2016-04-05T14:10:00.0h0Z                          |
      | my_time>=2016-04-05T14:10:00.,00L                          |
      | my_time==2016-04-05T14:00:00.00Z,,2017-04-05T14:00:00.00Z  |
      | my_time==2016-04-05T14:00:00.00Z...2017-04-05T14:00:00.00Z |

subscription request

POST http://localhost:1026/v2/subscriptions
Content-Type: application/json
Fiware-Service: test_condition_expression_error
Fiware-ServicePath: /test
{"notification": {"callback": "http://localhost:1234", "attributes": ["temperature"]}, "expires": "2016-04-05T14:00:00.00Z", "subject": {"entities": [{"idPattern": ".*", "type": "room"}], "condition": {"attributes": ["temperature"], "expression": {"q": "my_time==2016-04-05T14:00:00.00Z...2017-04-05T14:00:00.00Z"}}}}

subscription response

http code: 201
date: Mon, 04 Apr 2016 16:15:39 GMT
connection: Keep-Alive
content-length: 0
location: /v2/subscriptions/5702975c1119929c19e4f443

mongo docs

{ "_id" : ObjectId("570297591119929c19e4f430"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2r16-04-05T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f431"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=-04-05T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f432"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016_04-05T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f433"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-64-05T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f434"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016--05T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f435"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-r4-05T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f436"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-55T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f437"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-r5T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f438"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-T14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975a1119929c19e4f439"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05K14:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f43a"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T54:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f43b"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05Tr4:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f43c"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T:00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f43d"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14;00:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f43e"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14:r0:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f43f"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14:44:00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f440"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14::00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f441"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14:10-00.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975b1119929c19e4f442"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14:10:x0.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }
{ "_id" : ObjectId("5702975c1119929c19e4f443"), "expiration" : NumberLong(1459864800), "reference" : "http://localhost:1234", "throttling" : NumberLong(0), "servicePath" : "/test", "entities" : [ { "id" : ".*", "type" : "room", "isPattern" : "true" } ], "attrs" : [ "temperature" ], "conditions" : [ { "type" : "ONCHANGE", "value" : [ "temperature" ] } ], "expression" : { "q" : "my_time>=2016-04-05T14:10:0x.00Z", "geometry" : "", "coords" : "", "georel" : "" }, "format" : "JSON" }

expected response

http code: 400
{"error":"BadRequest","description":"invalid query expression"}
iariasleon commented 8 years ago

In the version:

  "version" : "1.0.0-next"
  "git_hash" : "fee3d035442e78c1a2e19720f68bdeba083ca560",

And they respond the payload in plain text (description) instead of json object :

http code: 200 - OK
headers:
     date: Mon, 02 May 2016 09:25:11 GMT
     fiware-correlator: c4b591e6-1047-11e6-bb3f-005056a20feb
     connection: Keep-Alive
     content-type: application/json
     content-length: 34
payload: lists only valid for == and != ops

cases:
| q                                                          | payload                            |
|------------------------------------------------------------|------------------------------------|
| my_time>=2016-04-05T14:10:00,00Z                           | lists only valid for == and != ops |
| my_time>=2016-04-05T14:10:00.,00L                          | lists only valid for == and != ops |
| my_time==2016-04-05T14:00:00.00Z,,2017-04-05T14:00:00.00Z  | empty item in list                 |  
| my_time==2016-04-05T14:00:00.00Z...2017-04-05T14:00:00.00Z | invalid range: types mixed         |
iariasleon commented 8 years ago

In CB version:

 "version" : "1.1.0-next",
  "git_hash" : "301c258a9ef8f05cabdc276b7e21365e8f4d5913"

These cases respond correctly, with a json object and the description see table below

| q                                                          | description                        |
|------------------------------------------------------------|------------------------------------|
| my_time>=2016-04-05T14:10:00,00Z                           | lists only valid for == and != ops |
| my_time>=2016-04-05T14:10:00.,00L                          | lists only valid for == and != ops |
| my_time==2016-04-05T14:00:00.00Z,,2017-04-05T14:00:00.00Z  | empty item in list                 |  
| my_time==2016-04-05T14:00:00.00Z...2017-04-05T14:00:00.00Z | invalid range: types mixed         |

But these case are responding 201 - OK

      | q                                                          | 
      |------------------------------------------------------------|
      | my_time<>2016-04-05T14:00:00.00Z                           | 
      | my_time>=2r16-04-05T14:00:00.00Z                           | 
      | my_time>=-04-05T14:00:00.00Z                               | 
      | my_time>=2016_04-05T14:00:00.00Z                           |
      | my_time>=2016-64-05T14:00:00.00Z                           | 
      | my_time>=2016--05T14:00:00.00Z                             | 
      | my_time>=2016-r4-05T14:00:00.00Z                           | 
      | my_time>=2016-04-55T14:00:00.00Z                           |
      | my_time>=2016-04-r5T14:00:00.00Z                           | 
      | my_time>=2016-04-T14:00:00.00Z                             | 
      | my_time>=2016-04-05K14:00:00.00Z                           | 
      | my_time>=2016-04-05T54:00:00.00Z                           | 
      | my_time>=2016-04-05Tr4:00:00.00Z                           | 
      | my_time>=2016-04-05T:00:00.00Z                             | 
      | my_time>=2016-04-05T14;00:00.00Z                           | 
      | my_time>=2016-04-05T14:r0:00.00Z                           | 
      | my_time>=2016-04-05T14:44:00.00Z                           | 
      | my_time>=2016-04-05T14::00.00Z                             | 
      | my_time>=2016-04-05T14:10-00.00Z                           | 
      | my_time>=2016-04-05T14:10:x0.00Z                           | 
      | my_time>=2016-04-05T14:10:0x.00Z                           | 
      | my_time>=2016-04-05T14:10:.00Z                             | 
      | my_time>=2016-04-05T14:10:00.h00Z                          | 
      | my_time>=2016-04-05T14:10:00.0h0Z                          |
iariasleon commented 8 years ago

Re-tested in the CB version. It issue still fails and returns 201-Created

  "version" : "1.2.0-next",
  "git_hash" : "d81dcf28e71d8d63dc0929ef7a6b73d7db47421b"
iariasleon commented 7 years ago

Re-tested in the CB version. It issue still fails and returns 201-Created

  "version" : "1.5.0-next"
  "git_hash" : "d943fb6827fdee0d7e89501c343dc252f6757f60"