homedepot / github-webhook-resource

Concourse resource for remotely managing GitHub webhooks
Apache License 2.0
12 stars 20 forks source link

Match existing hook without payload secret #55

Open totahuanocotl opened 2 months ago

totahuanocotl commented 2 months ago

What is the purpose of this pull request?

What changes did you make? (Give a brief overview) Change the desired hook config used to match against existing hooks to not include the secret property if its value is undefined.

Without this change, the _.isMatch function is not able to find a match in the existing pipelines, and attempts to create the webhook again, resulting in an api error.

The error returned by the resource before this changes looked like the following:

Error while calling Github: StatusCodeError
Response Status: 422
Message: {
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "Hook",
      "code": "custom",
      "message": "Hook already exists on this repository"
    },
    {
      "resource": "Hook",
      "code": "custom",
      "message": "Invalid config attribute: content-type"
    }
  ],
  "documentation_url": "https://docs.github.com/rest/repos/webhooks#create-a-repository-webhook",
  "status": "422"
}

Is there anything specific you would like reviewers to focus on? No

joshbrucker commented 4 weeks ago

@billimek @GavinFigueroa This looks like a good change that resolves an issue that our previous PR introduced.