[YANGTOOLS-804] Netconf response payload fails to render in JSON, only XML works in RestConf response Created: 03/Aug/17  Updated: 10/Apr/22  Resolved: 17/May/18

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

Type: Bug Priority: Highest
Reporter: JH Assignee: Balaji Varadaraju
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Attachments: Text File jsonoutputapi.txt     File show-system@2017-01-01.yang    
External issue ID: 8927

 Description   

Version: Boron-SR3.

Restconf call to Netconf-mounted router to fetch some data with Accept: json header results in severely truncated response payload.

The same call with Accept: xml header results in the entire payload correctly rendered.

Setting TRACE options for netconf within karaf shows the netconf data is indeed intact in the router's RPC response.

{set TRACE org.opendaylight.netconf.sal.connect.netconf, set TRACE org.opendaylight.netconf}

Attachments:
jsonoutputapi.txt:

  • Example RestConf method used
  • An example of the heavily-truncated JSON response
  • The correct payload in the XML response to the same method.
  • Snippet/example from karaf log showing Netconf RPC response payload
  • (also in karaf log) A suspicious (or not) WARN about leading LF (0a) character (which can be seen in the NetconfXMLToMessageDecoder raw netconf response payload).


 Comments   
Comment by JH [ 03/Aug/17 ]

Attachment jsonoutputapi.txt has been added with description: RestConf methods, output examples, and karaf log

Comment by Jakub Toth [ 10/Aug/17 ]

Hi,

Does it happen when you GET any data ? Or JSON Response is incomplete only while do you want to use RPC.

Thanks

Comment by Jakub Toth [ 10/Aug/17 ]

+ can you please add any testing yang with same structure ?

Comment by JH [ 15/Aug/17 ]

Attachment show-system@2017-01-01.yang has been added with description: Requested Yang model for RPC example

Comment by JH [ 15/Aug/17 ]

(In reply to Jakub Toth from comment #1)
> Hi,
>
> Does it happen when you GET any data ? Or JSON Response is incomplete only
> while do you want to use RPC.
>
> Thanks

GET appears to be working.

Thx

Comment by Balaji Varadaraju [ 05/Sep/17 ]

HI Jakub,
Do you need any more information on this? This happens when we use a specific RPC.

Comment by Balaji Varadaraju [ 11/Sep/17 ]

Hi Jakub,
Can you please let know the findings and progress on this issue? Thanks for your help.

Comment by Jakub Morvay [ 19/Sep/17 ]

Moving this to Restconf component, since this seems to be related to parsing of normalized nodes to JSON.

Particularly, I think there can be some issue with transforming anyxml rpc output normalized node to JSON.

Comment by Tomas Cere [ 03/Oct/17 ]

yangtools issue, unit test:
https://git.opendaylight.org/gerrit/63902

Comment by Peter Kajsa [ 05/Oct/17 ]

master: https://git.opendaylight.org/gerrit/#/c/63984/

Comment by Balaji Varadaraju [ 19/Oct/17 ]

I took the master distribution from

https://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/org/opendaylight/integration/karaf/0.8.0-SNAPSHOT/

after it is merged to master.

the exact build is

karaf-0.8.0-20171019.165729-765.zip Thu Oct 19 16:57:58 UTC 2017 328022058

I still see the same issue. I am no able to get the output in JSON for this request. XML works.

Is it the correct build? Can you please verify once.

Comment by Robert Varga [ 24/Oct/17 ]

Yangtools is currently disconnect from autorelease. This will be integrated with 2.0.0 release.

Comment by Atul Gosain [ 13/Nov/17 ]

I have put a patch for yangtools-1.2.x on https://git.opendaylight.org/gerrit/#/c/65394/4 . Please approve/merge it.

Comment by Robert Varga [ 14/Nov/17 ]

Reopening for integration in 1.2.2.

Comment by Atul Gosain [ 17/Nov/17 ]

We tested with the real input for the device for the same issue and this resulted in null pointer exception. Tested this input with the Unit test for bug8927/input.xml and got the same error back.
Following error is thrown when this input xml is sent
java.lang.NullPointerException
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeXmlValue(JSONNormalizedNodeStreamWriter.java:277)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeXmlNode(JSONNormalizedNodeStreamWriter.java:244)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeObject(JSONNormalizedNodeStreamWriter.java:269)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeXmlNode(JSONNormalizedNodeStreamWriter.java:251)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeObject(JSONNormalizedNodeStreamWriter.java:269)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeXmlNode(JSONNormalizedNodeStreamWriter.java:251)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeObject(JSONNormalizedNodeStreamWriter.java:269)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeXmlNode(JSONNormalizedNodeStreamWriter.java:251)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeObject(JSONNormalizedNodeStreamWriter.java:269)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeXmlNode(JSONNormalizedNodeStreamWriter.java:251)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.writeAnyXmlValue(JSONNormalizedNodeStreamWriter.java:238)
at org.opendaylight.yangtools.yang.data.codec.gson.JSONNormalizedNodeStreamWriter.anyxmlNode(JSONNormalizedNodeStreamWriter.java:206)
at org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter.wasProcessAsSimpleNode(NormalizedNodeWriter.java:153)
at org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter.write(NormalizedNodeWriter.java:101)
at org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter.writeChildren(NormalizedNodeWriter.java:169)
at org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter.wasProcessedAsCompositeNode(NormalizedNodeWriter.java:195)
at org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeWriter.write(NormalizedNodeWriter.java:97)
at org.opendaylight.yangtools.yang.data.codec.gson.TestUtils.normalizedNodesToJsonString(TestUtils.java:74)
at org.opendaylight.yangtools.yang.data.codec.gson.AnyXmlSupportTest.bug8927Test(AnyXmlSupportTest.java:149)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)

Following is the input xml for the failing test

<?xml version="1.0" encoding="UTF-8"?>
<root xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:junos="http://xml.juniper.net/junos/17.4X48/junos">
<foo xmlns="bug8927.test">
<multi-routing-engine-results xmlns="bug8927.test">

<multi-routing-engine-item>

<re-name>bsys-re0</re-name>

<alarm-information xmlns="bug8927.test">
<alarm-summary>
<active-alarm-count>11</active-alarm-count>
</alarm-summary>
<alarm-detail>
<alarm-time junos:seconds="1510607242">2017-11-13 21:07:22 UTC</alarm-time>
<alarm-class>Minor</alarm-class>
<alarm-description>N+1 Power redundancy missing in Upper zone</alarm-description>
<alarm-short-description>No Redundant Supply</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510599812">2017-11-13 19:03:32 UTC</alarm-time>
<alarm-class>Minor</alarm-class>
<alarm-description>N+1 Power redundancy missing in Lower zone</alarm-description>
<alarm-short-description>No Redundant Supply</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269219">2017-11-09 23:13:39 UTC</alarm-time>
<alarm-class>Minor</alarm-class>
<alarm-description>Check plane 2 Fabric Chip</alarm-description>
<alarm-short-description>Check plane 2 FCHIP</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 13</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 12</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 11</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 10</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 4</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 3</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 2</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
<alarm-detail>
<alarm-time junos:seconds="1510269022">2017-11-09 23:10:22 UTC</alarm-time>
<alarm-class>Major</alarm-class>
<alarm-description>No Input Feed Selected for PSM 1</alarm-description>
<alarm-short-description>No Input Feed Selec</alarm-short-description>
<alarm-type>Chassis</alarm-type>
</alarm-detail>
</alarm-information>
</multi-routing-engine-item>

<multi-routing-engine-item>

<re-name>gnf6-re0</re-name>

<alarm-information xmlns="http://xml.juniper.net/junos/17.4X48/junos-alarm">
<alarm-summary>
<no-active-alarms/>
</alarm-summary>
</alarm-information>
</multi-routing-engine-item>

</multi-routing-engine-results>
</foo>
</root>


module bug8927 {
namespace "bug8927.test";
prefix tst;

revision 2017-01-01 {
}

container foo

{ anyxml multi-routing-engine-results; }

}

Comment by Balaji Varadaraju [ 07/Dec/17 ]

Fix for nullpointer exception is here

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

Comment by Balaji Varadaraju [ 07/Dec/17 ]

However once we got through this hurdle, we tested some anyxmls fine. So we have made progress.

But looks like anyxml to JSON conversion does not handle arrays in XMLs. Looks like fundamentally there is an issue. What does below line result to? It expects the XML tag name to be a static string. The way i understand this can never be true.

ANYXML_ARRAY_ELEMENT_ID.equals(firstChildElement.getNodeName()

So anyxml to JSON needs the fix to handle arrays. 

Comment by Robert Varga [ 05/Apr/18 ]

Not only that, Atul's patch cause a NETCONF UT failure and was reverted.

Comment by Robert Varga [ 05/Apr/18 ]

De-targeted released versions. This issue looks like it's going to take some doing. Balaji: are you still working on it?

Comment by Balaji Varadaraju [ 05/Apr/18 ]

Yes Robert. I've submitted a patch in stable/carbon for your review. I think i have fixed this and tested with many RPCs that produce anyxml on real hardware devices. They produce the JSON response as expected.  I've also added a few unit tests. Once we review here I can add the same patch in other branches as per your suggestion.

 

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

Comment by Balaji Varadaraju [ 05/Apr/18 ]

Also this is not related to other patch that was reverted. That patch was about issuing http PATCH command on the Netconf devices. This one is just about rendering ANYXML in JSON format.

Comment by Atul Gosain [ 06/Apr/18 ]

Robert, im waiting for your comments on the patch that was reverted. Sent a mail to yangtools-dev and netconf-dev earlier this week.

Comment by Balaji Varadaraju [ 13/Apr/18 ]

rovarga can you please review the patch? It's been pending for a few weeks now. Thanks for your help.

Comment by Robert Varga [ 17/Apr/18 ]

bvaradar that patch needs some serious attention. Can you start by making it pass validation on master?

Comment by Balaji Varadaraju [ 17/Apr/18 ]

Thanks rovarga.

Master is pushed at  https://git.opendaylight.org/gerrit/#/c/71058/.

Addressed all comments.  Local build is green. Lets see the jenkins build.

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