Match existing hook without payload secret#55
Open
totahuanocotl wants to merge 1 commit intohomedepot:masterfrom
Open
Match existing hook without payload secret#55totahuanocotl wants to merge 1 commit intohomedepot:masterfrom
totahuanocotl wants to merge 1 commit intohomedepot:masterfrom
Conversation
The exsiting hook matcher started failing for the scenario where the
webhook does not define a payload_secret. It's content was set to
undefined, and the _.isMatch function used to filter the hooks was
returning undefined, as it didn't match any of the retrieved hooks,
even when it should have. This resulted in an attempt to create the
webhook, even if it exsited; github returned a 422 error.
This changes the desired config, to not include the secret property
if its value is undefined. With this change, the _.isMatch function
is able to find the match, and correctly updates or no-ops the hook.
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"
}
```
Contributor
|
@billimek @GavinFigueroa This looks like a good change that resolves an issue that our previous PR introduced. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Is there anything specific you would like reviewers to focus on?
No