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

Use of net.sf.json.JSONObject can lead to invalid marathon.json generation

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • marathon-plugin
    • None

      The Marathon plugin uses the net.sf.json.JSONObject class to deserialize the Marathon config. If a user accidentally includes a duplicate key (e.g. in env or labels), this class will combine the values of the duplicate keys into an array in the resulting generated Marathon config (in contrast to most JSON deserialization libraries, which pick the last key), leading to a schema violation when the plugin attempts to PUT the generated config to Marathon (this shows up as an HTTP 422 and no useful error message in Jenkins, due to JENKINS-37287).

      For example, if you have an env like this:

      {
        "foo": "bar",
        "foo": "baz"
      }
      

      The Marathon plugin will generate:

      {
        "foo": ["bar", "baz"]
      }
      
      

      Values in the 'env' hash are only allowed to be strings, not arrays, so this fails Marathon's JSON schema validation, leading to the HTTP 422.

            colinmsphere Colin
            jcmcken Jon McKenzie
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: