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] it is possible to append a new attribute metadata with forbidden metadata type #1232

Closed
iariasleon opened this issue Sep 14, 2015 · 3 comments
Assignees
Milestone

Comments

@iariasleon
Copy link
Contributor

Forbbiden metadatas types could be used in append request and it is inserted in the value field in attribute. See Updated documents in Mongo

Update attribute type

POST http://<host>:<port>/v2/entities/room_8
  Content-Type: application/json
  Fiware-Service: test_attribute_metadata_name_update_error
  Fiware-ServicePath: /test
   {"temperature": {"very_hot_0_0": {"type": "house(flat)", "value": "678"}}}

update response

 http code: 201 Created
 date: Wed, 09 Sep 2015 10:40:20 GMT
 content-length: 0
 location: /v2/entities/room_8

Datasets used:

 | attributes_type |
 |-----------------|
 | house<flat>     |
 | house=flat      |
 | house"flat"     |
 | house'flat'     |
 | house;flat      |
 | house(flat)     |
 | attributes_type       |
 |-----------------------|
 | false                 |
 | true                  |
 | 34                    |
 | {"a":34}              |
 | ["34", "a", 45]       |

Updated documents in Mongo

{ "_id" : { "id" : "room_2", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442226312, "modDate" : 1442226312, "value" : { "very_hot_0_0" : { "type" : "house<flat>", "value" : "678" } } } }, "creDate" : 1442226312, "modDate" : 1442226312 }
{ "_id" : { "id" : "room_3", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442226312, "modDate" : 1442226312, "value" : { "very_hot_0_0" : { "type" : "house=flat", "value" : "678" } } } }, "creDate" : 1442226312, "modDate" : 1442226312 }
{ "_id" : { "id" : "room_4", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442226312, "modDate" : 1442226312, "value" : { "very_hot_0_0" : { "type" : "house\"flat\"", "value" : "678" } } } }, "creDate" : 1442226312, "modDate" : 1442226312 }
{ "_id" : { "id" : "room_5", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442226312, "modDate" : 1442226312, "value" : { "very_hot_0_0" : { "type" : "house'flat'", "value" : "678" } } } }, "creDate" : 1442226312, "modDate" : 1442226312 }
{ "_id" : { "id" : "room_6", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442226312, "modDate" : 1442226312, "value" : { "very_hot_0_0" : { "type" : "house;flat", "value" : "678" } } } }, "creDate" : 1442226312, "modDate" : 1442226312 }
{ "_id" : { "id" : "room_8", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442226312, "modDate" : 1442226312, "value" : { "very_hot_0_0" : { "type" : "house(flat)", "value" : "678" } } } }, "creDate" : 1442226312, "modDate" : 1442226312 }
{ "_id" : { "id" : "room3", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442231180, "modDate" : 1442231180, "value" : { "very_cold" : { "type" : false, "value" : "hot" } } } }, "creDate" : 1442231180, "modDate" : 1442231180 }
{ "_id" : { "id" : "room4", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442231180, "modDate" : 1442231180, "value" : { "very_cold" : { "type" : true, "value" : "hot" } } } }, "creDate" : 1442231180, "modDate" : 1442231180 }
{ "_id" : { "id" : "room5", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442231180, "modDate" : 1442231180, "value" : { "very_cold" : { "type" : 34, "value" : "hot" } } } }, "creDate" : 1442231180, "modDate" : 1442231180 }
{ "_id" : { "id" : "room6", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442231180, "modDate" : 1442231180, "value" : { "very_cold" : { "type" : { "a" : 34 }, "value" : "hot" } } } }, "creDate" : 1442231180, "modDate" : 1442231180 }
{ "_id" : { "id" : "room7", "servicePath" : "/test" }, "attrNames" : [ "temperature" ], "attrs" : { "temperature" : { "type" : "", "creDate" : 1442231180, "modDate" : 1442231180, "value" : { "very_cold" : { "type" : [ "34", "a", 45 ], "value" : "hot" } } } }, "creDate" : 1442231180, "modDate" : 1442231180 }

@fgalan
Copy link
Member

fgalan commented Sep 15, 2015

This issue is related with the JSON format for representing entities/attributes/metadata, which is currently under discussion. Thus, it has been deferred to milestone 0.26.0.

@fgalan fgalan modified the milestones: 1259-cluster, 0.26.0 Oct 5, 2015
@raconte
Copy link
Contributor

raconte commented Jan 22, 2016

Create entity (POST)

(curl localhost:1026/v2/entities/ -s -S --header Content-Type:application/json --header 'Accept: application/json' -d @-| python -mjson.tool)<< EOF
{
    "type": "house",
    "temperature": {
        "type": "celcius",
        "value": "34",
        "metadata": {
            "very_hot_0_0": {
                "type": "celcius",
                "value": "23"
            }
        }
    },
    "id": "room_27"
}
EOF

Update with forbidden metadata type

(curl localhost:1026/v2/entities/room_27 -s -S --header Content-Type:application/json --header 'Accept: application/json' -d @-| python -mjson.tool)<< EOF
{
    "temperature": {
        "type": "celcius",
        "value": "34",
        "metadata": {
            "very_hot_0_0": {
                "type": "house(flat)",
                "value": "23"
            }   
        }
    }
}
EOF

The response is :

{
    "description": "Invalid characters in metadata type",
    "error": "BadRequest"
}

Solved

@iariasleon
Copy link
Contributor Author

LGTM
This issue is fixed, but others characters as: ?, / or # still fail, See #1782

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

3 participants