[CONTROLLER-230] Error 500 on GET/OPTIONS Created: 24/Mar/14  Updated: 25/Jul/23  Resolved: 11/Sep/14

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

Type: Bug
Reporter: Wojciech Dec Assignee: Unassigned
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Mac OS
Platform: PC


External issue ID: 573
Priority: Normal

 Description   

On doing a GET
http://<device>:8080/restconf/config/opendaylight-inventory:nodes/nod
e/<device>/yang-ext:mount/Cisco-IOS-XR-ipv4-io-oper:ipv4-network

ODL receive sends an 500 HTTP error, with the following output. Possibly a netconf problem...

<html><head><title>Apache Tomcat/7.0.32 - Error report</title><style><!--H1

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;}

H2

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;}

H3

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;}

BODY

{font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;}

B

{font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;}

P

{font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}

A

{color : black;}

A.name

{color : black;}

HR

{color : #525D76;}

--></style> </head><body><h1>HTTP Status 500 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Exception report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The server encountered an internal error that prevented it from fulfilling this request.</u></p><p><b>exception</b> <pre>java.lang.NullPointerException
org.opendaylight.yangtools.yang.data.impl.codec.xml.XmlDocumentUtils.toDomNodes(XmlDocumentUtils.java:430)
org.opendaylight.controller.sal.connect.netconf.NetconfMapping.toRpcResult(NetconfMapping.java:377)
org.opendaylight.controller.sal.connect.netconf.NetconfDevice.invokeRpc(NetconfDevice.java:463)
org.opendaylight.controller.sal.connect.netconf.NetconfDevice.readConfigurationData(NetconfDevice.java:414)
org.opendaylight.controller.sal.connect.netconf.NetconfDevice.readConfigurationData(NetconfDevice.java:79)
org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter$1.apply(AbstractDataReadRouter.java:71)
org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter$1.apply(AbstractDataReadRouter.java:68)
com.google.common.collect.Iterators$8.transform(Iterators.java:860)
com.google.common.collect.TransformedIterator.next(TransformedIterator.java:48)
org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter.merge(DataReaderRouter.java:75)
org.opendaylight.controller.sal.dom.broker.impl.DataReaderRouter.merge(DataReaderRouter.java:38)
org.opendaylight.controller.md.sal.common.impl.routing.AbstractDataReadRouter.readConfigurationData(AbstractDataReadRouter.java:40)
org.opendaylight.controller.md.sal.common.impl.service.AbstractDataBroker.readConfigurationData(AbstractDataBroker.java:191)
org.opendaylight.controller.sal.dom.broker.MountPointImpl.readConfigurationData(MountPointImpl.java:83)
org.opendaylight.controller.sal.restconf.impl.BrokerFacade.readConfigurationDataBehindMountPoint(BrokerFacade.java:106)
org.opendaylight.controller.sal.restconf.impl.RestconfImpl.readConfigurationData(RestconfImpl.java:203)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
java.lang.reflect.Method.invoke(Method.java:606)
com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$TypeOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:185)
com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:302)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.ResourceObjectRule.accept(ResourceObjectRule.java:100)
com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1511)
com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1442)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1391)
com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1381)
com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:538)
com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:716)
javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
org.apache.catalina.filters.CorsFilter.handleNonCORS(CorsFilter.java:440)
org.apache.catalina.filters.CorsFilter.doFilter(CorsFilter.java:179)
</pre></p><p><b>note</b> <u>The full stack trace of the root cause is available in the Apache Tomcat/7.0.32 logs.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.32</h3></body></html>



 Comments   
Comment by Tony Tkacik [ 28/Mar/14 ]

Please make sure if the ietf-inet-types and ietf-yang-types are in cache/schema folder. Some network devices fail to provide this YANG modules, and reading anything IP related then will fail in similar extension.

Comment by Tony Tkacik [ 28/Mar/14 ]

Please make sure if the ietf-inet-types and ietf-yang-types are in cache/schema folder. Some network devices fail to provide this YANG modules, and reading anything IP related then will fail in similar extension.

Comment by Wojciech Dec [ 28/Mar/14 ]

Hi,

yes, the schema are all there. I traced down the problem to the following however:
The GET that produces the server error is for a config resource, which actually is an operational resource in the yang model.
Correct behavior IMO would be to send an HTTP Error 400 - bad request.

Comment by Tony Tkacik [ 02/Apr/14 ]

Changed to enhancement, since this is improving error reporting.

Comment by Wojciech Dec [ 02/Apr/14 ]

Sending a GET for a resource foo that is not in the data store should return an Error 400. Replying with an Error 500 (server error + java backtrace) does not appear to be proper, and it doesn't look like an enhancement, esp since it is also not compliant with the Restconf spec.

It is also inconsistent with the rest of the RESTConf ASPI response codes, which when interrogated with a GET for a non existing item "foo" in the data tree returns an Error 400: URI has bad format. "foo" was not found in parent data node.

Comment by Wojciech Dec [ 02/Apr/14 ]

Same behavior observed on OPTIONS.

Comment by Wojciech Dec [ 23/May/14 ]

Changing back to bug, since it's in effect an improperly handled exception.

Comment by Tom Pantelis [ 28/May/14 ]

At the very least the NullPointerException is a bug and should be fixed. The code path has since changed so the methods/line numbers don't match the trace above but it looks like line 430 in XmlDocumentUtils.toDomNode is here:

NodeList nodes = element.getChildNodes();
...
--> for (int i = 0; i < nodes.getLength(); i++) {

So getChildNodes returned null which indicates an empty root element. We should protect against that. I suspect the device returned a valid response but with no data.

Whether rest should report 400 or 404 is another story. Basically the mount point is a pass thru to the device so rest should report whatever the device reports. If the query was invalid then the device should report it as such but apparently it didn't.

Comment by Tony Tkacik [ 11/Sep/14 ]

This bug is observed in old code path to Netconf, which is not actual anymore. Unable to reproduce with new code path to Netconf.

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