Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Log unknown GitHub events in webhook #1082

Merged
merged 3 commits into from Nov 18, 2020

Conversation

zli-simspace
Copy link
Contributor

While troubleshooting an issue, I see in our logs.

    ** (FunctionClauseError) no function clause matching in BorsNG.WebhookController.do_webhook/3

Unfortunately the error that follows shows only the first argument conn truncated and not the important second and third arguments.

Solution

Similar to do_webhook_pr, I've added a do_webhook clause to log the unknown cases. I have it return a 404 (so its close to the previous behaviour of returning a 500) but suggestions for a different behaviour are welcome.

Test

Tested by running

curl -X POST localhost:8000/webhook/github -H 'x-github-event: bogus' -d "{}"

with signature checking temporarily disabled and saw

[info] WebhookController: Got unknown Github event: bogus

in the server output.

@notriddle
Copy link
Member

bors r+

bors bot added a commit that referenced this pull request Nov 17, 2020
1080: Bump copy-webpack-plugin from 6.1.0 to 6.3.1 in /assets r=notriddle a=dependabot-preview[bot]

Bumps [copy-webpack-plugin](https://github.com/webpack-contrib/copy-webpack-plugin) from 6.1.0 to 6.3.1.


1082: Log unknown GitHub events in webhook r=notriddle a=zli-simspace

While troubleshooting an issue, I see in our logs.

```
    ** (FunctionClauseError) no function clause matching in BorsNG.WebhookController.do_webhook/3
```

Unfortunately the error that follows shows only the first argument `conn` truncated and not the important second and third arguments.

## Solution

Similar to `do_webhook_pr`, I've added a `do_webhook` clause to log the unknown cases. I have it return a 404 (so its close to the previous behaviour of returning a 500) but suggestions for a different behaviour are welcome.

## Test

Tested by running

```
curl -X POST localhost:8000/webhook/github -H 'x-github-event: bogus' -d "{}"
```

with signature checking temporarily disabled and saw

```
[info] WebhookController: Got unknown Github event: bogus
```

in the server output.

1083: Fix MatchError from wrong number of values returned. r=notriddle a=zli-simspace

In commit 9c555f8, the result of the first branch in

```
      case toml_result do
        {:ok, toml} -> {toml.delete_merged_branches, toml.update_base_for_deletes}
        _ -> false
      end
```

is updated but not the second branch, resulting in a MatchError.

This small PR fixes that.

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: zli <zli@simspace.com>
@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

This PR was included in a batch that timed out, it will be automatically retried

bors bot added a commit that referenced this pull request Nov 17, 2020
1081: Bump tesla from 1.3.3 to 1.4.0 r=notriddle a=dependabot-preview[bot]

Bumps [tesla](https://github.com/teamon/tesla) from 1.3.3 to 1.4.0.


1082: Log unknown GitHub events in webhook r=notriddle a=zli-simspace

While troubleshooting an issue, I see in our logs.

```
    ** (FunctionClauseError) no function clause matching in BorsNG.WebhookController.do_webhook/3
```

Unfortunately the error that follows shows only the first argument `conn` truncated and not the important second and third arguments.

## Solution

Similar to `do_webhook_pr`, I've added a `do_webhook` clause to log the unknown cases. I have it return a 404 (so its close to the previous behaviour of returning a 500) but suggestions for a different behaviour are welcome.

## Test

Tested by running

```
curl -X POST localhost:8000/webhook/github -H 'x-github-event: bogus' -d "{}"
```

with signature checking temporarily disabled and saw

```
[info] WebhookController: Got unknown Github event: bogus
```

in the server output.

1083: Fix MatchError from wrong number of values returned. r=notriddle a=zli-simspace

In commit 9c555f8, the result of the first branch in

```
      case toml_result do
        {:ok, toml} -> {toml.delete_merged_branches, toml.update_base_for_deletes}
        _ -> false
      end
```

is updated but not the second branch, resulting in a MatchError.

This small PR fixes that.

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: zli <zli@simspace.com>
@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

Build failed (retrying...):

  • continuous-integration/travis-ci/push

bors bot added a commit that referenced this pull request Nov 17, 2020
1082: Log unknown GitHub events in webhook r=notriddle a=zli-simspace

While troubleshooting an issue, I see in our logs.

```
    ** (FunctionClauseError) no function clause matching in BorsNG.WebhookController.do_webhook/3
```

Unfortunately the error that follows shows only the first argument `conn` truncated and not the important second and third arguments.

## Solution

Similar to `do_webhook_pr`, I've added a `do_webhook` clause to log the unknown cases. I have it return a 404 (so its close to the previous behaviour of returning a 500) but suggestions for a different behaviour are welcome.

## Test

Tested by running

```
curl -X POST localhost:8000/webhook/github -H 'x-github-event: bogus' -d "{}"
```

with signature checking temporarily disabled and saw

```
[info] WebhookController: Got unknown Github event: bogus
```

in the server output.

1083: Fix MatchError from wrong number of values returned. r=notriddle a=zli-simspace

In commit 9c555f8, the result of the first branch in

```
      case toml_result do
        {:ok, toml} -> {toml.delete_merged_branches, toml.update_base_for_deletes}
        _ -> false
      end
```

is updated but not the second branch, resulting in a MatchError.

This small PR fixes that.

Co-authored-by: zli <zli@simspace.com>
@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

Build failed (retrying...):

  • continuous-integration/travis-ci/push

bors bot added a commit that referenced this pull request Nov 17, 2020
1082: Log unknown GitHub events in webhook r=notriddle a=zli-simspace

While troubleshooting an issue, I see in our logs.

```
    ** (FunctionClauseError) no function clause matching in BorsNG.WebhookController.do_webhook/3
```

Unfortunately the error that follows shows only the first argument `conn` truncated and not the important second and third arguments.

## Solution

Similar to `do_webhook_pr`, I've added a `do_webhook` clause to log the unknown cases. I have it return a 404 (so its close to the previous behaviour of returning a 500) but suggestions for a different behaviour are welcome.

## Test

Tested by running

```
curl -X POST localhost:8000/webhook/github -H 'x-github-event: bogus' -d "{}"
```

with signature checking temporarily disabled and saw

```
[info] WebhookController: Got unknown Github event: bogus
```

in the server output.

Co-authored-by: zli <zli@simspace.com>
@bors
Copy link
Contributor

bors bot commented Nov 17, 2020

Build failed:

@notriddle
Copy link
Member

** (Mix) mix format failed due to --check-formatted.

The following files were not formatted:

  * lib/web/controllers/webhook_controller.ex

@zli-simspace
Copy link
Contributor Author

Thanks! Should be fixed now.

Reran mix format --check-formatted locally to confirm.

Copy link
Member

@notriddle notriddle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Nov 18, 2020

@bors bors bot merged commit c40a30c into bors-ng:master Nov 18, 2020
notriddle added a commit to bors-ng/bors-ng.github.io that referenced this pull request Dec 2, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants