Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-25315

Nested views do not properly round-trip through REST or CLI due to missing View.owner

      If you retrieve a NestedView from either REST (GET /view/.../config.xml) or CLI (get-view), and then save it right back (POST /view/.../config.xml, update-view or create-view after deleting), the resulting view does not render. Depending on the subview you get either

      java.lang.NullPointerException
          hudson.model.View._getOwnerItemGroup(View.java:269)
          hudson.model.View.getOwnerItemGroup(View.java:258)
          hudson.model.ListView.getItems(ListView.java:168)
          hudson.model.ListView.getItems(ListView.java:66)
          hudson.model.View.filterQueue(View.java:462)
          hudson.model.View.getApproximateQueueItemsQuickly(View.java:483)
      

      or

      java.lang.NullPointerException: Cannot invoke method isEmpty() on null object
          org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77)
          org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
          org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
          org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32)
          org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
          java_util_List$isEmpty.call(Unknown Source)
          hudson.model.View.main.run(main.groovy:6)
      

      (both stack traces from 1.554.x).

      The reason is that View.writeXml explicitly omits the View.owner field when writing, yet NestedView.views makes no attempt to restore it when loading XML.

      The workaround is to add

      <owner class="hudson.plugins.nested_view.NestedView" reference="../../.."/>
      

      inside every nested view (<hudson.model.ListView> etc.) before sending the XML back to Jenkins.

          [JENKINS-25315] Nested views do not properly round-trip through REST or CLI due to missing View.owner

          Jesse Glick created issue -
          Jesse Glick made changes -
          Remote Link New: This issue links to "PR 19 (Web Link)" [ 11810 ]
          Jesse Glick made changes -
          Status Original: Open [ 1 ] New: In Progress [ 3 ]
          Jesse Glick made changes -
          Assignee New: Jesse Glick [ jglick ]
          R. Tyler Croy made changes -
          Workflow Original: JNJira [ 159232 ] New: JNJira + In-Review [ 185541 ]
          Jesse Glick made changes -
          Status Original: In Progress [ 3 ] New: In Review [ 10005 ]
          Jesse Glick made changes -
          Link New: This issue relates to JENKINS-41825 [ JENKINS-41825 ]

          Jesse Glick added a comment -

          Merged, awaiting 1.15 release. Thanks lvotypkova!

          Jesse Glick added a comment - Merged, awaiting 1.15 release. Thanks lvotypkova !
          Jesse Glick made changes -
          Resolution New: Fixed [ 1 ]
          Status Original: In Review [ 10005 ] New: Resolved [ 5 ]

          Jakob Glass added a comment -

          Is the 1.15 release going to happen? I noticed it's been two months since this comment, and no updated release is out yet... Plus the plugin says it is up for adoption.

          Jakob Glass added a comment - Is the 1.15 release going to happen? I noticed it's been two months since this comment, and no updated release is out yet... Plus the plugin says it is up for adoption.

            jglick Jesse Glick
            jglick Jesse Glick
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: