[CONTROLLER-752] When saving over data which already exists the JSON response contains forward slash. Created: 01/Sep/14  Updated: 05/Sep/14  Resolved: 05/Sep/14

Status: Resolved
Project: controller
Component/s: restconf
Affects Version/s: Helium
Fix Version/s: None

Type: Bug
Reporter: RichardHill Assignee: Tony Tkacik
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


External issue ID: 1661

 Description   

I am raising this as a bug because the presence or (lack of) of '/' leads to inconsistencies in describing the expected response.

TEST ENV
org.opendaylight.controller.version = 0.1
org.opendaylight.controller.build.scm.version = 78fec1c1c5a3720bd48d1044703824626f08b5d9
org.opendaylight.controller.build.user = jenkins-controller
org.opendaylight.controller.build.workspace = **********
org.opendaylight.controller.build.timestamp = 1409283738738
org.opendaylight.controller.build.machine = **********

I tried to save data which already exists in datastore in JSON format to a location behind /config root. I then tried to invoke an error response by saving the same data again. No special config was used.

Steps

method is: post
uri is: /restconf/config/opendaylight-inventory:nodes
headers is:

{'content-type': 'application/json', 'accept': 'application/json'}

data is: {
"opendaylight-inventory:node":[

{ "id":"id2" }

]
}
expected_status is: 204

and then repeat

method is: post
uri is: /restconf/config/opendaylight-inventory:nodes
headers is:

{'content-type': 'application/json', 'accept': 'application/json'}

data is: {
"opendaylight-inventory:node":[

{ "id":"id2" }

]
}
expected_status is: 409
expected response is

{
"errors": {
"error": [
{
"error-message": "Data already exists for path: (urn:opendaylight:inventory?revision=2013-08-19)nodes(urn:opendaylight:inventory?revision=2013-08-19)node[

{(urn:opendaylight:inventory?revision=2013-08-19)id=id2}

]",
"error-tag": "data-exists",
"error-type": "protocol"
}
]
}
}

ACTUAL RESPONSE

{
"errors": {
"error": [
{
"error-type": "protocol",
"error-tag": "data-exists",
"error-message": "Data already exists for path: /(urn:opendaylight:inventory?revision=2013-08-19)nodes/node/node[

{(urn:opendaylight:inventory?revision=2013-08-19)id=id2}

]"
}
]
}
}

NOTES
The path on the "error message" key also looks wrong. nodes is duplicated.



 Comments   
Comment by Tony Tkacik [ 05/Sep/14 ]

Is there problem with forward slash? escaping is suggested only for Javascript,
not JSON.
The JSON RFC in Section 7 http://tools.ietf.org/html/rfc7159#section-7
explicitly states characters which needs to be escaped and forward slash (solidus)
is not listed there.

The representation of strings is similar to conventions used in the C
family of programming languages. A string begins and ends with
quotation marks. All Unicode characters may be placed within the
quotation marks, except for the characters that must be escaped:
quotation mark, reverse solidus, and the control characters (U+0000
through U+001F).

Also path returned in error message represents internal format used in ODL not restconf and is for information purposes and may change, since its contents
is not formally defined or required by specification.

Generated at Wed Feb 07 19:53:47 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.