[CONTROLLER-472] Restconf errors should be formatted in JSON as appropropriate Created: 14/May/14  Updated: 27/May/14  Resolved: 27/May/14

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

Type: Bug
Reporter: Rob Adams Assignee: Tom Pantelis
Resolution: Done 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: 1010

 Description   

Requests to restconf API should always return data in the appropriate content type.

Currently, returns errors either as plain text string:

$ curl -X POST -H 'Content-Type: application/yang.data+json' -d '{toaster:{darknessFactor: "2000"}}' http://localhost:8080/restconf/config/toaster:toaster
Data has bad format. Root element node must have namespace (XML format) or module name(JSON format)

or as an HTML formatted exception:
$ curl -X POST -H 'Content-Type: application/yang.data+json' -d '{"toaster:toaster":{"darknessFactor": "2000"}}' http://localhost:8080/restconf/config/toaster:toaster
<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
com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper.unwrap(SimpleNodeWrapper.java:82)
org.opendaylight.controller.sal.restconf.impl.SimpleNodeWrapper.unwrap(SimpleNodeWrapper.java:21)
org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper.unwrap(CompositeNodeWrapper.java:109)
org.opendaylight.controller.sal.restconf.impl.CompositeNodeWrapper.getNodeType(CompositeNodeWrapper.java:123)
<SNIP>



 Comments   
Comment by Tom Pantelis [ 16/May/14 ]

In addition to returning error data in the appropriate content type, error data should also be returned in the form described by the "errors" schema in the RESTCONF RFC section 6: https://tools.ietf.org/html/draft-bierman-netconf-restconf-02#section-6.

Comment by Tom Pantelis [ 16/May/14 ]

I have prototyped the changes but it depends on the current work to add the missing ietf-restconf yang module which hopefully should get merged soon.

Comment by Tom Pantelis [ 20/May/14 ]

Pushed draft:

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

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