<!-- 
RSS generated by JIRA (8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d) at Wed Feb 07 20:16:45 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>OpenDaylight JIRA</title>
    <link>https://jira.opendaylight.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>8.20.10</version>
        <build-number>820010</build-number>
        <build-date>22-06-2022</build-date>
    </build-info>


<item>
            <title>[NETCONF-1130] (devices) POST returns 500 on data already exists</title>
                <link>https://jira.opendaylight.org/browse/NETCONF-1130</link>
                <project id="10142" key="NETCONF">netconf</project>
                    <description>&lt;p&gt;Successfully create a resource of your choice on device using POST request. Then invoke the same request again, for example:&lt;/p&gt;

&lt;p&gt;POST&#160;&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;http://localhost:8181/rests/data/network-topology:network-topology/topology=topology-netconf/node=17830-sim-device/yang-ext:mount&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
{
&#160; &lt;span class=&quot;code-quote&quot;&gt;&quot;toaster:toaster&quot;&lt;/span&gt;: {
&#160; &#160; &lt;span class=&quot;code-quote&quot;&gt;&quot;toasterManufacturer&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;pantheon&quot;&lt;/span&gt;,
&#160; &#160; &lt;span class=&quot;code-quote&quot;&gt;&quot;toasterModelNumber&quot;&lt;/span&gt;: 25,
&#160; &#160; &lt;span class=&quot;code-quote&quot;&gt;&quot;toasterStatus&quot;&lt;/span&gt;: &lt;span class=&quot;code-quote&quot;&gt;&quot;up&quot;&lt;/span&gt;,
&#160; &#160; &lt;span class=&quot;code-quote&quot;&gt;&quot;darknessFactor&quot;&lt;/span&gt;: 1000
&#160; }
} &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;We get the error response (500 Internal Server Error):&lt;/p&gt;
&lt;div class=&quot;preformatted panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;preformattedContent panelContent&quot;&gt;
&lt;pre&gt;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;
&#160; &#160; &amp;lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html;charset=ISO-8859-1&quot; /&amp;gt;
&#160; &#160; &amp;lt;title&amp;gt;Error 500 Internal Server Error&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;
&#160; &#160; &amp;lt;h2&amp;gt;HTTP ERROR 500 Internal Server Error&amp;lt;/h2&amp;gt;
&#160; &#160; &amp;lt;table&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;tr&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;th&amp;gt;URI:&amp;lt;/th&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;td&amp;gt;/rests/data/network-topology:network-topology/topology=topology-netconf/node=17830-sim-device/yang-ext:mount
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;/td&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;/tr&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;tr&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;th&amp;gt;STATUS:&amp;lt;/th&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;td&amp;gt;500&amp;lt;/td&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;/tr&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;tr&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;th&amp;gt;MESSAGE:&amp;lt;/th&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;td&amp;gt;Internal Server Error&amp;lt;/td&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;/tr&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;tr&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;th&amp;gt;SERVLET:&amp;lt;/th&amp;gt;
&#160; &#160; &#160; &#160; &#160; &#160; &amp;lt;td&amp;gt;org.glassfish.jersey.servlet.ServletContainer&amp;lt;/td&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;/tr&amp;gt;
&#160; &#160; &amp;lt;/table&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;According to RFC 8040 we should get 409 Conflict. Something similar to:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
&amp;lt;errors xmlns=&lt;span class=&quot;code-quote&quot;&gt;&quot;urn:ietf:params:xml:ns:yang:ietf-restconf&quot;&lt;/span&gt;&amp;gt;
&#160; &#160; &amp;lt;error&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;error-type&amp;gt;protocol&amp;lt;/error-type&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;error-tag&amp;gt;data-exists&amp;lt;/error-tag&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;error-path
&#160; &#160; &#160; &#160; xmlns:rc=&lt;span class=&quot;code-quote&quot;&gt;&quot;urn:ietf:params:xml:ns:yang:ietf-restconf&quot;&lt;/span&gt;
&#160; &#160; &#160; &#160; xmlns:jbox=&lt;span class=&quot;code-quote&quot;&gt;&quot;https:&lt;span class=&quot;code-comment&quot;&gt;//example.com/ns/example-jukebox&quot;&lt;/span&gt;&amp;gt;\
&lt;/span&gt;&#160; &#160; &#160; &#160; /rc:restconf/rc:data/jbox:jukebox
&#160; &#160; &#160; &#160; &amp;lt;/error-path&amp;gt;
&#160; &#160; &#160; &#160; &amp;lt;error-message&amp;gt;
&#160; &#160; &#160; &#160; Data already exists; cannot create &lt;span class=&quot;code-keyword&quot;&gt;new&lt;/span&gt; resource
&#160; &#160; &#160; &#160; &amp;lt;/error-message&amp;gt;
&#160; &#160; &amp;lt;/error&amp;gt;
&amp;lt;/errors&amp;gt;&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;</description>
                <environment></environment>
        <key id="37191">NETCONF-1130</key>
            <summary>(devices) POST returns 500 on data already exists</summary>
                <type id="10104" iconUrl="https://jira.opendaylight.org/secure/viewavatar?size=xsmall&amp;avatarId=10303&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.opendaylight.org/images/icons/priorities/major.svg">Medium</priority>
                        <status id="5" iconUrl="https://jira.opendaylight.org/images/icons/statuses/resolved.png" description="A resolution has been taken, and it is awaiting verification by reporter. From here issues are either reopened, or are closed.">Resolved</status>
                    <statusCategory id="3" key="done" colorName="green"/>
                                    <resolution id="10000">Done</resolution>
                                        <assignee username="yaroslav.lastivka">Yaroslav Lastivka</assignee>
                                    <reporter username="ivanhrasko">Ivan Hrasko</reporter>
                        <labels>
                            <label>pt</label>
                    </labels>
                <created>Thu, 10 Aug 2023 10:33:02 +0000</created>
                <updated>Mon, 22 Jan 2024 12:59:40 +0000</updated>
                            <resolved>Mon, 22 Jan 2024 12:59:40 +0000</resolved>
                                    <version>5.0.7</version>
                    <version>4.0.8</version>
                    <version>6.0.1</version>
                                    <fixVersion>7.0.0</fixVersion>
                    <fixVersion>5.0.10</fixVersion>
                    <fixVersion>6.0.6</fixVersion>
                                    <component>restconf-nb</component>
                        <due></due>
                            <votes>0</votes>
                                    <watches>4</watches>
                                                                                                                <comments>
                            <comment id="72439" author="ivanhrasko" created="Fri, 11 Aug 2023 08:12:02 +0000"  >&lt;p&gt;It seems that we do not check if data already exists for default value of insert (&lt;b&gt;last&lt;/b&gt;): &lt;a href=&quot;https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.5.&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://datatracker.ietf.org/doc/html/rfc8040#section-4.8.5.&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;See &lt;b&gt;PostDataTransactionUtil#submitData&lt;/b&gt;.&lt;/p&gt;

&lt;p&gt;In addition, we need unit test coverage for this scenario.&lt;/p&gt;</comment>
                            <comment id="72529" author="petersuna" created="Fri, 8 Sep 2023 10:15:27 +0000"  >&lt;p&gt;The issue arises only when the device produces an error. The device generates the correct response with an appropriate NetconfDocumentedException error. This exception is then mapped to a RestconfDocumentedException in the &lt;a href=&quot;https://github.com/opendaylight/netconf/blob/master/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/rests/utils/TransactionUtil.java#L130&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;TransactionUtil#decodeException&lt;/a&gt; method, along with the YangInstanceIdentifier path of the device schema, for example: &quot;/(&lt;a href=&quot;http://netconfcentral.org/ns/toaster2?revision=2009-11-20)toaster/darknessFactor&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;http://netconfcentral.org/ns/toaster2?revision=2009-11-20)toaster/darknessFactor&lt;/a&gt;&quot;.&#160;&lt;/p&gt;

&lt;p&gt;Subsequently, this RestconfDocumentedException is mapped to a JSON/XML Response in the RestconfDocumentedExceptionMapper, using the SchemaContext of the controller. &#160;Notably, this SchemaContext does not include the models of the device.&lt;/p&gt;

&lt;p&gt;The path of the device model is added to the &quot;error-path&quot; leaf and validated by the Controller SchemaContext. This validation process results in a Mapper exception, leading to a 500 error, as seen in the following log snippet:&lt;/p&gt;
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
2023-09-05T12:38:46,308 | ERROR | qtp1936609051-682 | ServerRuntime$Responder          | 172 - org.glassfish.jersey.core.jersey-server - 2.40.0 | An exception has been thrown from an exception mapper &lt;span class=&quot;code-keyword&quot;&gt;class &lt;/span&gt;org.opendaylight.restconf.nb.rfc8040.jersey.providers.errors.RestconfDocumentedExceptionMapper.
java.lang.IllegalArgumentException: Invalid input /(http:&lt;span class=&quot;code-comment&quot;&gt;//netconfcentral.org/ns/toaster2?revision=2009-11-20)toaster/darknessFactor: schema &lt;span class=&quot;code-keyword&quot;&gt;for&lt;/span&gt; argument (http://netconfcentral.org/ns/toaster2?revision=2009-11-20)toaster (after ) not found
&lt;/span&gt;	at com.google.common.base.Preconditions.checkArgument(Preconditions.java:463) ~[bundleFile:?]
	at org.opendaylight.yangtools.yang.data.util.AbstractStringInstanceIdentifierCodec.serializeImpl(AbstractStringInstanceIdentifierCodec.java:53) ~[bundleFile:?]&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;p&gt;&#160;&lt;/p&gt;

&lt;p&gt;The simplest solution for this issue would be removing validation for &quot;error-path&quot;, similar to what is done for the &lt;a href=&quot;https://github.com/opendaylight/netconf/blob/master/restconf/restconf-nb/src/main/java/org/opendaylight/restconf/nb/rfc8040/jersey/providers/errors/StreamWriterWithDisabledValidation.java#L29&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;&quot;error-info&quot; leaf&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;A more complex solution would involve retaining the validation and adding the Device schema context to the RestconfDocumentedExceptionMapper. Here are suggested steps for this solution:&lt;/p&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;RestconfDocumentedExceptionMapper will have DOMMountPointService in his constructor.&lt;/li&gt;
	&lt;li&gt;RestconfDocumentedException will have option to add UriInfo in the constructor.&lt;/li&gt;
	&lt;li&gt;Then we can create Inference stack for the device in method RestconfDocumentedExceptionMapper#toResponse as follows:&#160;&lt;/li&gt;
&lt;/ul&gt;


&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
&lt;span class=&quot;code-keyword&quot;&gt;if&lt;/span&gt; (exception.getUriInfo() != &lt;span class=&quot;code-keyword&quot;&gt;null&lt;/span&gt;) {
    &lt;span class=&quot;code-keyword&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; identifierContext = ParserIdentifier.toInstanceIdentifier(
        exception.getUriInfo().getPathParameters(&lt;span class=&quot;code-keyword&quot;&gt;false&lt;/span&gt;).getFirst(&lt;span class=&quot;code-quote&quot;&gt;&quot;identifier&quot;&lt;/span&gt;),
        databindProvider.currentContext().modelContext(), mountPointService);
    &lt;span class=&quot;code-keyword&quot;&gt;final&lt;/span&gt; &lt;span class=&quot;code-keyword&quot;&gt;var&lt;/span&gt; deviceInference = identifierContext.inference();

} &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;ul class=&quot;alternate&quot; type=&quot;square&quot;&gt;
	&lt;li&gt;Use this device Inference for creating a NormalizedNodeStreamWriter:
&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
jsonNodeStreamWriter = JSONNormalizedNodeStreamWriter.createExclusiveWriter(databindContext.jsonCodecs(),
inference, IETF_RESTCONF_URI, jsonWriter);


xmlNodeStreamWriter = XMLStreamNormalizedNodeStreamWriter.create(xmlWriter, inference); &lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;&lt;/li&gt;
&lt;/ul&gt;
</comment>
                            <comment id="72536" author="rovarga" created="Tue, 12 Sep 2023 17:01:51 +0000"  >&lt;p&gt;So actually we should be taking a similar approach to what we do in JSONDataTreeCandidateFormatter (and XML as well). There we talk directly to a JsonWriter and then move to JsonDataTreeCandidateSerializer &amp;#8211; which again emits some things directly through JsonWriter and emits other things through a nested JSONNormalizedNodeStreamWriter.&lt;/p&gt;

&lt;p&gt;In this particular case, we want to emit pretty much everything directly, except for the YangInstanceIdentifier.&lt;br/&gt;
In DTCL formatters the EffectiveModelContext is always local, so we get away with just emitting startLeafNode()/scalarValue() for emitting the YangInstanceIdentifier (see &lt;a href=&quot;https://jira.opendaylight.org/browse/NETCONF-1152&quot; title=&quot;RESTCONF DataTreeChange notifications use incorrect format&quot; class=&quot;issue-link&quot; data-issue-key=&quot;NETCONF-1152&quot;&gt;&lt;del&gt;NETCONF-1152&lt;/del&gt;&lt;/a&gt;).&lt;br/&gt;
Here we do not have that luxury and need help from yang-data-codec-&lt;/p&gt;
{json,xml}
&lt;p&gt;: their codecs need to expose a YangInstanceIdentifier codec which just emits the encoding into an open element (in XML case) or value(String):&lt;/p&gt;

&lt;div class=&quot;code panel&quot; style=&quot;border-width: 1px;&quot;&gt;&lt;div class=&quot;codeContent panelContent&quot;&gt;
&lt;pre class=&quot;code-java&quot;&gt;
   XmlCodecFactory codecFactory; &lt;span class=&quot;code-comment&quot;&gt;// corresponding to device context
&lt;/span&gt;   XMLStreamWriter xmlWriter; &lt;span class=&quot;code-comment&quot;&gt;// bound to OutputStream
&lt;/span&gt;   xmlWriter.writeStartElement(&lt;span class=&quot;code-quote&quot;&gt;&quot;error-path&quot;&lt;/span&gt;);
   codecFactory.instanceIdentifierSerializer().serializeTo(xmlWriter, path);
   xmlWriter.writeEndElement();
&lt;/pre&gt;
&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;The resulting document contract is tied to the request URI &amp;#8211; e.g. users reading need to understand they used yang-ext:mount and interpret things accordingly.&lt;/p&gt;</comment>
                            <comment id="72539" author="JIRAUSER13318" created="Thu, 14 Sep 2023 17:06:52 +0000"  >&lt;p&gt;&#160;I believe this is a duplicate of&#160;&lt;a href=&quot;https://jira.opendaylight.org/browse/NETCONF-782&quot; class=&quot;external-link&quot; rel=&quot;nofollow&quot;&gt;NETCONF-782&lt;/a&gt;.&lt;/p&gt;</comment>
                            <comment id="72540" author="rovarga" created="Thu, 14 Sep 2023 18:37:42 +0000"  >&lt;p&gt;Yes, it is a duplicate, but its solution is somewhat different and more in kind with eating our own dogfood.&lt;/p&gt;</comment>
                            <comment id="72541" author="rovarga" created="Thu, 14 Sep 2023 18:39:27 +0000"  >&lt;p&gt;&lt;a href=&quot;https://git.opendaylight.org/gerrit/c/netconf/+/107877&quot; class=&quot;external-link&quot; target=&quot;_blank&quot; rel=&quot;nofollow noopener&quot;&gt;https://git.opendaylight.org/gerrit/c/netconf/+/107877&lt;/a&gt; fixes a related bug: in those two places we just do a straight-up YangInstanceIdentifier.toString().&lt;/p&gt;</comment>
                            <comment id="72613" author="rovarga" created="Fri, 22 Sep 2023 23:27:24 +0000"  >&lt;p&gt;Reported stack trace should have a tad different structure.&lt;/p&gt;</comment>
                    </comments>
                <issuelinks>
                            <issuelinktype id="10000">
                    <name>Blocks</name>
                                                                <inwardlinks description="is blocked by">
                                        <issuelink>
            <issuekey id="37332">YANGTOOLS-1541</issuekey>
        </issuelink>
            <issuelink>
            <issuekey id="37415">YANGTOOLS-1543</issuekey>
        </issuelink>
                            </inwardlinks>
                                    </issuelinktype>
                            <issuelinktype id="10002">
                    <name>Duplicate</name>
                                            <outwardlinks description="duplicates">
                                        <issuelink>
            <issuekey id="34068">NETCONF-782</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                            <issuelinktype id="10003">
                    <name>Relates</name>
                                            <outwardlinks description="relates to">
                                        <issuelink>
            <issuekey id="37412">YANGTOOLS-1542</issuekey>
        </issuelink>
                            </outwardlinks>
                                                        </issuelinktype>
                    </issuelinks>
                <attachments>
                            <attachment id="19103" name="karaf.log" size="422949" author="PeterSuna" created="Fri, 8 Sep 2023 10:16:22 +0000"/>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                            <customfield id="customfield_11400" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                <customfield id="customfield_10000" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>0|i0468n:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                </customfields>
    </item>
</channel>
</rss>