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

    XMLWordPrintable

Details

    Description

      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.

      Attachments

        Issue Links

          Activity

            jglick Jesse Glick added a comment -

            Merged, awaiting 1.15 release. Thanks lvotypkova!

            jglick Jesse Glick added a comment - Merged, awaiting 1.15 release. Thanks lvotypkova !
            invenitive 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.

            invenitive 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.

            People

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

              Dates

                Created:
                Updated:
                Resolved: