tomzo / gocd-json-config-plugin

GoCD configuration plugin which supports JSON format
Apache License 2.0
41 stars 23 forks source link

NullPointerException when material type is missing #47

Open moritz opened 5 years ago

moritz commented 5 years ago

When a material has no type attribute, the GoCD Config repo admin screen reports:

runtime;
1. Unexpected error when handling plugin response
java.lang.NullPointerException

I would have expected an error message along the lines of "Material No. 1 of pipeline dummy has no attribute 'type'" or something like that.

This is a sample material I've used to reproduce this behavior:

"materials": [
    {
      "auto_update": false,
      "branch": "master",
      "destination": "dummy",
      "filter": {
        "ignore": [],
        "whitelist": []
      },
      "name": "dummy",
      "shallow_clone": false,
      "url": "https://github.com/gocd/build_map.git"
    }

This bug happens with GoCD Version: 19.3.0 (8959-259d1f79e361875995072e5c1fcc9cbda7ccc600).

In case it makes the reproduction of this bug easier, here is the full JSON of the the pipeline:

{
  "environment_variables": [],
  "group": "misc",
  "label_template": "${COUNT}",
  "lock_behavior": "none",
  "materials": [
    {
      "auto_update": false,
      "branch": "master",
      "destination": "dummy",
      "filter": {
        "ignore": [],
        "whitelist": []
      },
      "name": "dummy",
      "shallow_clone": false,
      "url": "https://github.com/gocd/build_map.git"
    }
  ],
  "name": "dummy",
  "stages": [
    {
      "approval": {
        "roles": [],
        "type": "success",
        "users": []
      },
      "clean_working_directory": true,
      "environment_variables": [],
      "fetch_materials": true,
      "jobs": [
        {
          "artifacts": [],
          "environment_variables": [],
          "name": "dummy",
          "properties": [],
          "resources": [
            "stretch"
          ],
          "run_instance_count": "0",
          "tabs": [],
          "tasks": [
            {
              "arguments": [
                "test"
              ],
              "command": "echo",
              "run_if": "passed",
              "timeout": -1,
              "type": "exec",
              "working_directory": "dummy"
            }
          ],
          "timeout": 10
        }
      ],
      "name": "dummy",
      "never_cleanup_artifacts": false
    }
  ]
}