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

XML API Logs Too Much Information When Invalid Char is Present

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      When an XPath error occurs when calling the /api/xml API, the entire xml string writer object is included as part of the exception. While this could be useful in some circumstances, it poses a problem when there is a significant amount of xml (i.e. tens or hundreds of megabytes).

      Recently I saw this in my jenkins installation. One of the chrome extensions calls "/api/xml?depth=2&xpath=/*/job/lastBuild&wrapper=hudson" to get information every minute or two. I was seeing 150MB of log data every time that call was made because there was a stack trace followed by:

      Caused by: hudson.util.IOException2: Failed to do XPath/wrapper handling. XML is as follows:<hudson><assignedLabel><busyExecutors>0</busyExecutors><description>... [150MB of xml]</hudson>
      at hudson.model.Api.doXml(Api.java:142)
      ... 63 more
      Caused by: org.dom4j.DocumentException: Error on line 2170 of document : An invalid XML character (Unicode: 0x10) was found in the element content of the document. Nested exception: An invalid XML character (Unicode: 0x10) was found in the element content of the document.
      at org.dom4j.io.SAXReader.read(SAXReader.java:482)
      at org.dom4j.io.SAXReader.read(SAXReader.java:365)
      at hudson.model.Api.doXml(Api.java:100)
      ... 63 more
      Caused by: org.xml.sax.SAXParseException: An invalid XML character (Unicode: 0x10) was found in the element content of the document.
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195)
      at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174)
      at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388)
      at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2894)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
      at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
      at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
      at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
      at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
      at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
      at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
      at org.dom4j.io.SAXReader.read(SAXReader.java:465)
      ... 65 more

      It didn't take very long for the log file to consume all of the available disk space on the server and thereby halt the jenkins service.

      Clearly there is something wrong with the XML document or XPath requests, but the log file shouldn't cripple my system as a result.

      I marked this as Major because it can halt the jenkins service.

        Attachments

          Activity

          Hide
          thomasvandoren Thomas Van Doren added a comment -

          The specific XPath error logging issue is address in pull request 428.

          https://github.com/jenkinsci/jenkins/pull/428

          Show
          thomasvandoren Thomas Van Doren added a comment - The specific XPath error logging issue is address in pull request 428. https://github.com/jenkinsci/jenkins/pull/428
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Thomas Van Doren
          Path:
          core/src/main/java/hudson/model/Api.java
          http://jenkins-ci.org/commit/jenkins/668a0cc4dc786dc1b6a726b17db74e9974afa82a
          Log:
          [FIXED JENKINS-13378] Remove XML string writer from IOException2 when XPath error occurs.

          Remove XML string writer from IOException2 message when XPath error
          occurs in /api/xml request.

          The XML string writer has the potential to be very large (many
          megabytes or even gigabytes) and these exceptions will be logged to
          the default jenkins logfile by winstone. This has the potential to
          quickly use all available disk space if, for example, a jenkins poller
          (i.e. a chrome extension) makes frequent calls to the API that cause
          errors.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Thomas Van Doren Path: core/src/main/java/hudson/model/Api.java http://jenkins-ci.org/commit/jenkins/668a0cc4dc786dc1b6a726b17db74e9974afa82a Log: [FIXED JENKINS-13378] Remove XML string writer from IOException2 when XPath error occurs. Remove XML string writer from IOException2 message when XPath error occurs in /api/xml request. The XML string writer has the potential to be very large (many megabytes or even gigabytes) and these exceptions will be logged to the default jenkins logfile by winstone. This has the potential to quickly use all available disk space if, for example, a jenkins poller (i.e. a chrome extension) makes frequent calls to the API that cause errors.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Thomas Van Doren
          Path:
          core/src/main/java/hudson/model/Api.java
          http://jenkins-ci.org/commit/jenkins/e1a1d3f098d938fb9c4690cd283653a91a496ae6
          Log:
          JENKINS-13378 Add FINER logging of XML when XPath handling fails.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Thomas Van Doren Path: core/src/main/java/hudson/model/Api.java http://jenkins-ci.org/commit/jenkins/e1a1d3f098d938fb9c4690cd283653a91a496ae6 Log: JENKINS-13378 Add FINER logging of XML when XPath handling fails.
          Hide
          scm_issue_link SCM/JIRA link daemon added a comment -

          Code changed in jenkins
          User: Thomas Van Doren
          Path:
          changelog.html
          http://jenkins-ci.org/commit/jenkins/752a7c7b8bd357f2962c0b361eef465b1fd1c83f
          Log:
          JENKINS-13378 Update changelog.html with fix.

          Show
          scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Thomas Van Doren Path: changelog.html http://jenkins-ci.org/commit/jenkins/752a7c7b8bd357f2962c0b361eef465b1fd1c83f Log: JENKINS-13378 Update changelog.html with fix.
          Hide
          dogfood dogfood added a comment -

          Integrated in jenkins_main_trunk #1740
          [FIXED JENKINS-13378] Remove XML string writer from IOException2 when XPath error occurs. (Revision 668a0cc4dc786dc1b6a726b17db74e9974afa82a)
          JENKINS-13378 Add FINER logging of XML when XPath handling fails. (Revision e1a1d3f098d938fb9c4690cd283653a91a496ae6)
          JENKINS-13378 Update changelog.html with fix. (Revision 752a7c7b8bd357f2962c0b361eef465b1fd1c83f)

          Result = UNSTABLE
          thomas.vandoren : 668a0cc4dc786dc1b6a726b17db74e9974afa82a
          Files :

          • core/src/main/java/hudson/model/Api.java

          thomas.vandoren : e1a1d3f098d938fb9c4690cd283653a91a496ae6
          Files :

          • core/src/main/java/hudson/model/Api.java

          thomas.vandoren : 752a7c7b8bd357f2962c0b361eef465b1fd1c83f
          Files :

          • changelog.html
          Show
          dogfood dogfood added a comment - Integrated in jenkins_main_trunk #1740 [FIXED JENKINS-13378] Remove XML string writer from IOException2 when XPath error occurs. (Revision 668a0cc4dc786dc1b6a726b17db74e9974afa82a) JENKINS-13378 Add FINER logging of XML when XPath handling fails. (Revision e1a1d3f098d938fb9c4690cd283653a91a496ae6) JENKINS-13378 Update changelog.html with fix. (Revision 752a7c7b8bd357f2962c0b361eef465b1fd1c83f) Result = UNSTABLE thomas.vandoren : 668a0cc4dc786dc1b6a726b17db74e9974afa82a Files : core/src/main/java/hudson/model/Api.java thomas.vandoren : e1a1d3f098d938fb9c4690cd283653a91a496ae6 Files : core/src/main/java/hudson/model/Api.java thomas.vandoren : 752a7c7b8bd357f2962c0b361eef465b1fd1c83f Files : changelog.html
          Hide
          dogfood dogfood added a comment -

          Integrated in jenkins_ui-changes_branch #30
          [FIXED JENKINS-13378] Remove XML string writer from IOException2 when XPath error occurs. (Revision 668a0cc4dc786dc1b6a726b17db74e9974afa82a)
          JENKINS-13378 Add FINER logging of XML when XPath handling fails. (Revision e1a1d3f098d938fb9c4690cd283653a91a496ae6)
          JENKINS-13378 Update changelog.html with fix. (Revision 752a7c7b8bd357f2962c0b361eef465b1fd1c83f)

          Result = SUCCESS
          thomas.vandoren : 668a0cc4dc786dc1b6a726b17db74e9974afa82a
          Files :

          • core/src/main/java/hudson/model/Api.java

          thomas.vandoren : e1a1d3f098d938fb9c4690cd283653a91a496ae6
          Files :

          • core/src/main/java/hudson/model/Api.java

          thomas.vandoren : 752a7c7b8bd357f2962c0b361eef465b1fd1c83f
          Files :

          • changelog.html
          Show
          dogfood dogfood added a comment - Integrated in jenkins_ui-changes_branch #30 [FIXED JENKINS-13378] Remove XML string writer from IOException2 when XPath error occurs. (Revision 668a0cc4dc786dc1b6a726b17db74e9974afa82a) JENKINS-13378 Add FINER logging of XML when XPath handling fails. (Revision e1a1d3f098d938fb9c4690cd283653a91a496ae6) JENKINS-13378 Update changelog.html with fix. (Revision 752a7c7b8bd357f2962c0b361eef465b1fd1c83f) Result = SUCCESS thomas.vandoren : 668a0cc4dc786dc1b6a726b17db74e9974afa82a Files : core/src/main/java/hudson/model/Api.java thomas.vandoren : e1a1d3f098d938fb9c4690cd283653a91a496ae6 Files : core/src/main/java/hudson/model/Api.java thomas.vandoren : 752a7c7b8bd357f2962c0b361eef465b1fd1c83f Files : changelog.html

            People

            Assignee:
            thomasvandoren Thomas Van Doren
            Reporter:
            thomasvandoren Thomas Van Doren
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: