[YANGTOOLS-417] JSON PUT for list item does not work correctly Created: 12/Mar/15  Updated: 10/Apr/22  Resolved: 16/Mar/15

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Keith Burns Assignee: Tony Tkacik
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


External issue ID: 2818

 Description   

https://gist.github.com/2da83d35b8c8b11c3822

This worked fine Tue 5:30am when I built. Now we are hosed again.

It's very very hard not to rant when we change nothing, and either REST doesn't work for 2 days, or when it starts to work again, it breaks something else.

We are blocked.



 Comments   
Comment by Keith Burns [ 12/Mar/15 ]

The PUT to tenant has worked this way since:

commit 304445a4343a67e68fd6111edba6cba8cbaf7ac3
Author: Thomas Bachman <tbachman@yahoo.com>
Date: Mon Jan 19 17:03:23 2015 -0800

Fixed overwrite of tenant policy.

The existing script would overwrite any policy from tenant
and below, because of the URL used. This patch only adds
to the tenant list, instead of overwriting the whole thing.

Change-Id: Ia077b45a883fdd2d11cdd5775c28da6da7fb1a97
Signed-off-by: Thomas Bachman <tbachman@yahoo.com>

Comment by Ed Warnicke [ 12/Mar/15 ]

I have reproduced this error by:

cd groupbasedpolicy/
mvn clean install
cd distribution-karaf/target/assembly/bin
./karaf

Then using this postman:

https://www.getpostman.com/collections/d641d67f578c0abbf3d8

Doing 'Inventory PUT' (which works) followed by 'Policy PUT' (which gives the error Keith saw).

Comment by Ed Warnicke [ 12/Mar/15 ]

Note: When I try to use API-docs... API-docs thinks we have the policy model, and even shows the relavent things to GET and PUT... but they are breaking because the schema is missing.

Comment by Tony Tkacik [ 12/Mar/15 ]

JSON PUT does not work correctly after fixing POST for list items,

this bug has also its variation in https://jenkins.opendaylight.org/releng/view/CSIT-Jobs/job/openflowplugin-csit-1node-imds-flow-services-all-master/14/robot/report/log.html#s1-s4-s2-t3

Comment by Tony Tkacik [ 12/Mar/15 ]

Workaround is to wrap policy:tenant object in array as it is.

{
"policy:tenant": [{

}]
}

Seems yang-data-codec-gson does not handle parsing of one list item properly

3.2.4. The "list" Data Node

A sequence of one or more sibling XML elements with the same
qualified name that is modeled as YANG list is translated to a name/
array pair, and the array elements are JSON objects.

but implemented restconf draft provides examples for lists (which bit changes serialization of list):

https://tools.ietf.org/html/draft-bierman-netconf-restconf-02#page-37

Example from biermann

PUT /restconf/config/example-jukebox:jukebox/
library/artist/Foo%20Fighters/album/Wasting%20Light HTTP/1.1
Host: example.com
If-Match: b3830f23a4c
Content-Type: application/yang.data+json

{
"example-jukebox:album" :

{ "name" : "Wasting Light", "genre" : "example-jukebox:alternative", "year" : 2011 }

}

But by referenced YANG-JSON specification it should be
{
"example-jukebox:album" : [

{ "name" : "Wasting Light", "genre" : "example-jukebox:alternative", "year" : 2011 }

]
}

Comment by Tony Tkacik [ 12/Mar/15 ]

Seems this unclarity between specifications is still present in latest drafts:

https://tools.ietf.org/html/draft-ietf-netconf-restconf-04
https://tools.ietf.org/html/draft-ietf-netmod-yang-json-03#section-5.4

Where RESTCONF draft showcases reading list item returning
{ list: [{

}]
}

but PUT showcases
{ list : {

}
}

Comment by Tony Tkacik [ 12/Mar/15 ]

YANTools - https://git.opendaylight.org/gerrit/16405

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