[CONTROLLER-1191] Restconf PUT to top-level node fails Created: 10/Mar/15  Updated: 25/Jul/23  Resolved: 16/Mar/15

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

Type: Bug
Reporter: Tom Pantelis 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: 2805
Priority: High

 Comments   
Comment by Tom Pantelis [ 10/Mar/15 ]

If you do a PUT to a top-level node, an exception is thrown:

aylight.controller.sal-rest-connector - 1.2.0.SNAPSHOT | | Error parsing json input
java.util.NoSuchElementException
at com.google.common.collect.AbstractIndexedListIterator.next(AbstractIndexedListIterator.java:82)[114:com.google.guava:18.0.0]
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findNodeInSchemaContext(SchemaContextUtil.java:229)[141:org.opendaylight.yangtools.yang-model-util:0.7.0.SNAPSHOT]
at org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode(SchemaContextUtil.java:87)[141:org.opendaylight.yangtools.yang-model-util:0.7.0.SNAPSHOT]
at org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader.readFrom(JsonNormalizedNodeBodyReader.java:64)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader.readFrom(JsonNormalizedNodeBodyReader.java:41)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]

This is easily reproducible with the toaster, eg:

http://localhost:8181/restconf/config/toaster:toaster

{
toaster:

{ darknessFactor: "2000" }

}

Also the CDS 3-node integration tests that use the car/people models are broken as well.

Comment by Tom Pantelis [ 10/Mar/15 ]

Also doing POST to http://localhost:8181/restconf/config/, gets a different exception:

java.lang.NullPointerException
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)[114:com.google.guava:18.0.0]
at com.google.common.base.Splitter.split(Splitter.java:386)[114:com.google.guava:18.0.0]
at org.opendaylight.controller.sal.restconf.impl.ControllerContext.toIdentifier(ControllerContext.java:138)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.restconf.impl.ControllerContext.toInstanceIdentifier(ControllerContext.java:124)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider.getInstanceIdentifierContext(AbstractIdentifierAwareJaxRsProvider.java:24)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.rest.impl.AbstractIdentifierAwareJaxRsProvider.getIdentifierWithSchema(AbstractIdentifierAwareJaxRsProvider.java:20)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader.readFrom(JsonNormalizedNodeBodyReader.java:60)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]
at org.opendaylight.controller.sal.rest.impl.JsonNormalizedNodeBodyReader.readFrom(JsonNormalizedNodeBodyReader.java:41)[256:org.opendaylight.controller.sal-rest-connector:1.2.0.SNAPSHOT]

This is because the identifier portion of the URL was not specified. This is supposed to be allowed for POST (it used to work anyway).

Perhaps this should be a separate bug...

Comment by Tom Pantelis [ 10/Mar/15 ]

It looks like this may have been broken by https://git.opendaylight.org/gerrit/#/c/16209/2.

Comment by Tony Tkacik [ 10/Mar/15 ]

Yeah, in patch you mentioned is bug, which provides JSON failure for top-level element,
but without that patch JSON did not work at all.

Comment by Tom Pantelis [ 10/Mar/15 ]

ok - so there's progress - that's good

(In reply to Tony Tkacik from comment #4)
> Yeah, in patch you mentioned is bug, which provides JSON failure for
> top-level element,
> but without that patch JSON did not work at all.

Comment by Tony Tkacik [ 10/Mar/15 ]

https://git.opendaylight.org/gerrit/#/c/16136/

This fixes PUT for JSON inputs
and also POST for JSON/XML for creation of data and RPCs.

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