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

Buildgraph view does not show for some json responses

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Critical Critical
    • buildgraph-view-plugin
    • None
    • Buildgraph-view version 1.5
      Linux Ubuntu 16.04
      Firefox 51.01 64-bit
      Chrome 56 64-bit

      The symptom is that for specific build-flows the graph will not show up.
      The API json call will succeed but the graph will not render due to a javascript exception in buildgraph-appctrl.js:11

      The root cause is that the angular.js library, using the default HttpTransformResponse, given specific conditions will automatically parse the AJAX data as if it was json and return an object instead of the original string data. The JSON.parse on buildgraph-appctrl.js:11 will throw an exception if the data is an object.

      So what are the conditions for angular to do the automatic transformation?
      The important criteria that tricks up the rest of the implementation is its function isString() that only tests for typeof === "string"; but very specific invocations of String.replace and String.trim() used earlier in the code, will transform the data from a string literal type to a String() object. I know it sounds insane, but it has been confirmed in both Chrome and Firefox on a very specific set of data.

      The effect is that if we have the situation of replace() and trim() returns the data as a literal string, which HttpTransformResponse will convert to a javascript object which will fail the JSON.parse on line 11 in buildgraph-appctrl.js.
      If replace() and trim() returns a String-object, when reaching the HttpTransformResponse handler which will not convert it to an object since its isString() check will fail and the data will be returned as a String-object, which JSON.parse can handle and line 11 will succeed.

      We have not been

      Patch is on the way!

            per_bohlin Per Böhlin
            per_bohlin Per Böhlin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: